networkpolicy-ingress.yaml 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {{- if and .Values.networkPolicy.enabled (or .Values.networkPolicy.ingress.enabled .Values.networkPolicy.metrics.enabled .Values.networkPolicy.ingressRules.accessOnlyFrom.enabled) }}
  2. apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
  3. kind: NetworkPolicy
  4. metadata:
  5. name: {{ printf "%s-ingress" (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. {{- include "common.labels.standard" . | nindent 6 }}
  18. ingress:
  19. {{- if and .Values.ingress.enabled .Values.networkPolicy.ingress.enabled (or .Values.networkPolicy.ingress.namespaceSelector .Values.networkPolicy.ingress.podSelector) }}
  20. - from:
  21. {{- if .Values.networkPolicy.ingress.namespaceSelector }}
  22. - namespaceSelector:
  23. matchLabels:
  24. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingress.namespaceSelector "context" $) | nindent 14 }}
  25. {{- end }}
  26. {{- if .Values.networkPolicy.ingress.podSelector }}
  27. - podSelector:
  28. matchLabels:
  29. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingress.podSelector "context" $) | nindent 14 }}
  30. {{- end }}
  31. {{- end }}
  32. {{- if and .Values.metrics.enabled .Values.networkPolicy.metrics.enabled (or .Values.networkPolicy.metrics.namespaceSelector .Values.networkPolicy.metrics.podSelector) }}
  33. - from:
  34. {{- if .Values.networkPolicy.metrics.namespaceSelector }}
  35. - namespaceSelector:
  36. matchLabels:
  37. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.metrics.namespaceSelector "context" $) | nindent 14 }}
  38. {{- end }}
  39. {{- if .Values.networkPolicy.metrics.podSelector }}
  40. - podSelector:
  41. matchLabels:
  42. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.metrics.podSelector "context" $) | nindent 14 }}
  43. {{- end }}
  44. {{- end }}
  45. {{- if and .Values.networkPolicy.ingressRules.accessOnlyFrom.enabled (or .Values.networkPolicy.ingressRules.accessOnlyFrom.namespaceSelector .Values.networkPolicy.ingressRules.accessOnlyFrom.podSelector) }}
  46. - from:
  47. {{- if .Values.networkPolicy.ingressRules.accessOnlyFrom.namespaceSelector }}
  48. - namespaceSelector:
  49. matchLabels:
  50. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressRules.accessOnlyFrom.namespaceSelector "context" $) | nindent 14 }}
  51. {{- end }}
  52. {{- if .Values.networkPolicy.ingressRules.accessOnlyFrom.podSelector }}
  53. - podSelector:
  54. matchLabels:
  55. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressRules.accessOnlyFrom.podSelector "context" $) | nindent 14 }}
  56. {{- end }}
  57. {{- end }}
  58. {{- if .Values.networkPolicy.ingressRules.customRules }}
  59. {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressRules.customRules "context" $) | nindent 4 }}
  60. {{- end }}
  61. {{- end }}