networkpolicy.yaml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {{- if .Values.networkPolicy.enabled }}
  2. kind: NetworkPolicy
  3. apiVersion: networking.k8s.io/v1
  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. ingress:
  18. # Allow inbound connections to zookeeper
  19. - ports:
  20. - port: {{ .Values.service.port }}
  21. from:
  22. {{- if not .Values.networkPolicy.allowExternal }}
  23. - podSelector:
  24. matchLabels:
  25. {{ include "common.names.fullname" . }}-client: "true"
  26. - podSelector:
  27. matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
  28. {{- else }}
  29. - podSelector:
  30. matchLabels: {}
  31. {{- end }}
  32. # Internal ports
  33. - ports: &intranodes_ports
  34. - port: {{ .Values.service.followerPort }}
  35. - port: {{ .Values.service.electionPort }}
  36. from:
  37. - podSelector:
  38. matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
  39. egress:
  40. - ports: *intranodes_ports
  41. # Allow outbound connections from zookeeper nodes
  42. {{- end }}