Skip to content

Commit a8a972b

Browse files
committed
feat(cloudnative-pg): add optional networkPolicy
Signed-off-by: Pat Riehecky <riehecky@fnal.gov>
1 parent 8298eb9 commit a8a972b

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.networkPolicy.enabled }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ template "cloudnative-pg.fullname" . }}-network-policy
6+
namespace: {{ include "cloudnative-pg.namespace" . }}
7+
spec:
8+
egress:
9+
{{- with .Values.networkPolicy.egress }}
10+
{{- toYaml . | nindent 2 }}
11+
{{- end }}
12+
ingress:
13+
{{- with .Values.networkPolicy.ingress }}
14+
{{- toYaml . | nindent 2 }}
15+
{{- end }}
16+
podSelector:
17+
matchLabels:
18+
{{- include "cloudnative-pg.selectorLabels" . | nindent 6 }}
19+
policyTypes:
20+
- Egress
21+
- Ingress
22+
{{- end }}

charts/cloudnative-pg/values.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@
167167
"namespaceOverride": {
168168
"type": "string"
169169
},
170+
"networkPolicy": {
171+
"type": "object"
172+
},
170173
"nodeSelector": {
171174
"type": "object"
172175
},

charts/cloudnative-pg/values.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ webhook:
6666
failureThreshold: 6
6767
periodSeconds: 5
6868

69+
# Configure a networkPolicy for the operator
70+
networkPolicy:
71+
# -- Specifies whether the networkPolicy should be created.
72+
enabled: false
73+
# -- The ingress traffic
74+
# Should match the webhook and (optionally) metrics port
75+
ingress:
76+
- ports:
77+
- port: 8080 # metrics port
78+
protcol: TCP
79+
- port: 9443 # webhook port
80+
protcol: TCP
81+
# -- The egress traffic
82+
# This uses DNS (53/udp, 53/tcp) and the API server (80/tcp, 443/tcp, 6443/tcp)
83+
# OKD and Openshift use 6443/tcp
84+
egress:
85+
- ports:
86+
- port: 80
87+
protocol: TCP
88+
- port: 443
89+
protocol: TCP
90+
- port: 53
91+
protocol: TCP
92+
- port: 53
93+
protocol: UDP
94+
- port: 6443
95+
protocol: TCP
96+
6997
# Operator configuration.
7098
config:
7199
# -- Specifies whether the secret should be created.

0 commit comments

Comments
 (0)