networkpolicy.yaml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. {{- /*
  2. Copyright VMware, Inc.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{- if .Values.networkPolicy.enabled }}
  6. kind: NetworkPolicy
  7. apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
  8. metadata:
  9. name: {{ include "common.names.fullname" . }}
  10. namespace: {{ include "common.names.namespace" . | quote }}
  11. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  12. {{- if .Values.commonAnnotations }}
  13. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  14. {{- end }}
  15. spec:
  16. {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
  17. podSelector:
  18. matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
  19. ingress:
  20. # Allow inbound connections
  21. - ports:
  22. - port: {{ .Values.containerPorts.console }}
  23. - port: {{ .Values.containerPorts.api }}
  24. {{- if not .Values.networkPolicy.allowExternal }}
  25. from:
  26. - podSelector:
  27. matchLabels:
  28. {{ include "common.names.fullname" . }}-client: "true"
  29. - podSelector:
  30. matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 14 }}
  31. {{- if .Values.networkPolicy.extraFromClauses }}
  32. {{- toYaml .Values.networkPolicy.extraFromClauses | nindent 8 }}
  33. {{- end }}
  34. {{- end }}
  35. {{- end }}