Skip to content

Commit 0312c80

Browse files
committed
feat: add NetworkPolicy template
1 parent c15c052 commit 0312c80

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
@@ -724,3 +724,23 @@ nginxAgent:
724724
processorBufferSize: 50000
725725
## The name of a custom ConfigMap to use instead of the one provided by default
726726
customConfigMap: ""
727+
728+
# Default values for nginx-ingress with optional NetworkPolicy
729+
networkPolicy:
730+
enabled: false # Set to true to enable the NetworkPolicy
731+
policyTypes: # Types of policy to create
732+
- Ingress
733+
- Egress
734+
podSelector: {} # Label selector for pods (defaults to ingress controller pods)
735+
ingress: # Ingress rules
736+
- from: [] # List of peer selectors (e.g. namespaces, pods)
737+
ports:
738+
- protocol: TCP
739+
port: 80
740+
- protocol: TCP
741+
port: 443
742+
egress: # Egress rules
743+
- to: [] # List of peer selectors
744+
ports:
745+
- protocol: UDP
746+
port: 53

0 commit comments

Comments
 (0)