| Giorgi Lekveishvili | 8c99d62 | 2023-05-30 14:40:50 +0400 | [diff] [blame] | 1 | {{- if and .Values.networkPolicy.enabled (eq .Values.architecture "replication") .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.enabled }} |
| 2 | apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }} |
| 3 | kind: NetworkPolicy |
| 4 | metadata: |
| 5 | name: {{ printf "%s-ingress" (include "postgresql.readReplica.fullname" .) }} |
| 6 | namespace: {{ .Release.Namespace | quote }} |
| 7 | labels: {{- include "common.labels.standard" . | nindent 4 }} |
| 8 | app.kubernetes.io/component: read |
| 9 | {{- if .Values.commonLabels }} |
| 10 | {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} |
| 11 | {{- end }} |
| 12 | {{- if .Values.commonAnnotations }} |
| 13 | annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} |
| 14 | {{- end }} |
| 15 | spec: |
| 16 | podSelector: |
| 17 | matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} |
| 18 | app.kubernetes.io/component: read |
| 19 | ingress: |
| 20 | {{- if and .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.enabled (or .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.namespaceSelector .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.podSelector) }} |
| 21 | - from: |
| 22 | {{- if .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.namespaceSelector }} |
| 23 | - namespaceSelector: |
| 24 | matchLabels: {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.namespaceSelector "context" $) | nindent 14 }} |
| 25 | {{- end }} |
| 26 | {{- if .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.podSelector }} |
| 27 | - podSelector: |
| 28 | matchLabels: {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.podSelector "context" $) | nindent 14 }} |
| 29 | {{- end }} |
| 30 | ports: |
| 31 | - port: {{ .Values.containerPorts.postgresql }} |
| 32 | {{- end }} |
| 33 | {{- if .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.customRules }} |
| 34 | {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.customRules "context" $) | nindent 4 }} |
| 35 | {{- end }} |
| 36 | {{- end }} |