networkpolicy.yaml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {{- if .Values.networkPolicy.enabled }}
  2. kind: NetworkPolicy
  3. apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
  4. metadata:
  5. name: {{ include "common.names.fullname" . }}
  6. namespace: {{ template "zookeeper.namespace" . }}
  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: {{- include "common.labels.matchLabels" . | nindent 6 }}
  17. policyTypes:
  18. - Ingress
  19. ingress:
  20. # Allow inbound connections to ZooKeeper
  21. - ports:
  22. - port: {{ .Values.containerPorts.client }}
  23. {{- if .Values.metrics.enabled }}
  24. - port: {{ .Values.metrics.containerPort }}
  25. {{- end }}
  26. {{- if not .Values.networkPolicy.allowExternal }}
  27. from:
  28. - podSelector:
  29. matchLabels:
  30. {{ include "common.names.fullname" . }}-client: "true"
  31. - podSelector:
  32. matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
  33. {{- end }}
  34. # Allow internal communications between nodes
  35. - ports:
  36. - port: {{ .Values.containerPorts.follower }}
  37. - port: {{ .Values.containerPorts.election }}
  38. from:
  39. - podSelector:
  40. matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
  41. {{- end }}