Skip to content

feat: add NetworkPolicy template #8052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions charts/nginx-ingress/templates/controller-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "nginx-ingress.fullname" . }}-network-policy
labels:
{{- include "nginx-ingress.labels" . | nindent 4 }}
spec:
podSelector:
{{- toYaml .Values.networkPolicy.podSelector | nindent 4 }}
policyTypes:
{{- toYaml .Values.networkPolicy.policyTypes | nindent 4 }}

{{- if has "Ingress" .Values.networkPolicy.policyTypes }}
ingress:
{{- toYaml .Values.networkPolicy.ingress | nindent 4 }}
{{- end }}

{{- if has "Egress" .Values.networkPolicy.policyTypes }}
egress:
{{- toYaml .Values.networkPolicy.egress | nindent 4 }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/nginx-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,23 @@ nginxAgent:
processorBufferSize: 50000
## The name of a custom ConfigMap to use instead of the one provided by default
customConfigMap: ""

# Default values for nginx-ingress with optional NetworkPolicy
networkPolicy:
enabled: false # Set to true to enable the NetworkPolicy
policyTypes: # Types of policy to create
- Ingress
- Egress
podSelector: {} # Label selector for pods (defaults to ingress controller pods)
ingress: # Ingress rules
- from: [] # List of peer selectors (e.g. namespaces, pods)
ports:
- protocol: TCP
port: 80
- protocol: TCP
port: 443
egress: # Egress rules
- to: [] # List of peer selectors
ports:
- protocol: UDP
port: 53