Files
charts/bitnami/milvus/templates/proxy/networkpolicy.yaml
2023-09-07 14:15:46 +02:00

84 lines
3.5 KiB
YAML

{{- /*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.proxy.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
metadata:
name: {{ template "milvus.proxy.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: milvus
app.kubernetes.io/component: proxy
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.proxy.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/part-of: milvus
app.kubernetes.io/component: proxy
policyTypes:
- Ingress
- Egress
egress:
# Allow dns resolution
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow outbound connections to other cluster pods
- ports:
- port: {{ .Values.queryCoord.service.ports.grpc }}
- port: {{ .Values.dataCoord.service.ports.grpc }}
- port: {{ .Values.indexCoord.service.ports.grpc }}
- port: {{ .Values.rootCoord.service.ports.grpc }}
- port: {{ .Values.queryNode.service.ports.grpc }}
- port: {{ .Values.dataNode.service.ports.grpc }}
- port: {{ .Values.indexNode.service.ports.grpc }}
- port: {{ .Values.proxy.service.ports.grpc }}
- port: {{ include "milvus.etcd.port" . }}
- port: {{ include "milvus.s3.port" . }}
- port: {{ include "milvus.kafka.port" . }}
to:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
{{- if .Values.proxy.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.proxy.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
ingress:
- ports:
- port: {{ .Values.proxy.service.ports.grpc }}
{{- if not .Values.proxy.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels:
{{ template "common.names.fullname" . }}-client: "true"
{{- end }}
{{- if .Values.proxy.networkPolicy.ingressNSMatchLabels }}
- namespaceSelector:
matchLabels:
{{- range $key, $value := .Values.proxy.networkPolicy.ingressNSMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- if .Values.proxy.networkPolicy.ingressNSPodMatchLabels }}
podSelector:
matchLabels:
{{- range $key, $value := .Values.proxy.networkPolicy.ingressNSPodMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.proxy.metrics.enabled }}
- ports:
- port: {{ .Values.proxy.service.ports.metrics }}
{{- end }}
{{- if .Values.proxy.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.proxy.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}