networkpolicy.yaml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. {{- if .Values.networkPolicy.enabled }}
  2. kind: NetworkPolicy
  3. apiVersion: {{ template "common.capabilities.networkPolicy.apiVersion" . }}
  4. metadata:
  5. name: {{ template "common.names.fullname" . }}
  6. namespace: {{ include "common.names.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. {{- include "common.labels.matchLabels" . | nindent 6 }}
  18. ingress:
  19. # Allow inbound connections
  20. - ports:
  21. - port: {{ .Values.primary.service.ports.mysql }}
  22. {{- if not .Values.networkPolicy.allowExternal }}
  23. from:
  24. - podSelector:
  25. matchLabels:
  26. {{ template "common.names.fullname" . }}-client: "true"
  27. {{- if .Values.networkPolicy.explicitNamespacesSelector }}
  28. namespaceSelector:
  29. {{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }}
  30. {{- end }}
  31. - podSelector:
  32. matchLabels:
  33. {{- include "common.labels.matchLabels" . | nindent 14 }}
  34. {{- end }}
  35. {{- if .Values.metrics.enabled }}
  36. # Allow prometheus scrapes
  37. - ports:
  38. - port: 9104
  39. {{- end }}
  40. {{- end }}