Skip to content

Commit 24d1f83

Browse files
GabboPennahaywoodsh
authored andcommitted
feat: add NetworkPolicy template
1 parent 862d367 commit 24d1f83

File tree

2 files changed

+43
-0
lines changed

2 files changed

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

charts/nginx-ingress/values.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,3 +766,23 @@ nginxAgent:
766766
processorBufferSize: 50000
767767
## The name of a custom ConfigMap to use instead of the one provided by default
768768
customConfigMap: ""
769+
770+
# Default values for nginx-ingress with optional NetworkPolicy
771+
networkPolicy:
772+
enabled: false # Set to true to enable the NetworkPolicy
773+
policyTypes: # Types of policy to create
774+
- Ingress
775+
- Egress
776+
podSelector: {} # Label selector for pods (defaults to ingress controller pods)
777+
ingress: # Ingress rules
778+
- from: [] # List of peer selectors (e.g. namespaces, pods)
779+
ports:
780+
- protocol: TCP
781+
port: 80
782+
- protocol: TCP
783+
port: 443
784+
egress: # Egress rules
785+
- to: [] # List of peer selectors
786+
ports:
787+
- protocol: UDP
788+
port: 53

0 commit comments

Comments
 (0)