networkpolicy-egress.yaml 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. {{- if and .Values.networkPolicy.enabled (or .Values.networkPolicy.egressRules.denyConnectionsToExternal .Values.networkPolicy.egressRules.customRules) }}
  2. apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
  3. kind: NetworkPolicy
  4. metadata:
  5. name: {{ printf "%s-egress" (include "common.names.fullname" .) }}
  6. namespace: {{ .Release.Namespace | quote }}
  7. labels: {{- include "common.labels.standard" . | nindent 4 }}
  8. {{- if .Values.commonLabels }}
  9. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  10. {{- end }}
  11. {{- if .Values.commonAnnotations }}
  12. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  13. {{- end }}
  14. spec:
  15. podSelector:
  16. matchLabels:
  17. app.kubernetes.io/instance: {{ .Release.Name }}
  18. policyTypes:
  19. - Egress
  20. egress:
  21. {{- if .Values.networkPolicy.egressRules.denyConnectionsToExternal }}
  22. - ports:
  23. - port: 53
  24. protocol: UDP
  25. - port: 53
  26. protocol: TCP
  27. - to:
  28. - namespaceSelector: {}
  29. {{- end }}
  30. {{- if .Values.networkPolicy.egressRules.customRules }}
  31. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.egressRules.customRules "context" $) | nindent 4 }}
  32. {{- end }}
  33. {{- end }}