Skip to content

Commit

Permalink
added configurable ingress network policy to helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
imuni4fun committed Dec 20, 2024
1 parent f2eb0cb commit b7f200a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 11 additions & 4 deletions charts/oneShotMetricsServer/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if .Values.netpol.generate }}
{{ if ((.Values.netpol).generate) | default false }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
Expand All @@ -12,9 +12,16 @@ spec:
- namespaceSelector:
matchLabels:
name: {{ .Values.serviceNamespace | required "serviceNamespace is required" }}
podSelector:
matchLabels:
app.kubernetes.io/name: {{ .Values.serviceName | required "serviceName is required" }}
{{- range $ns := (.Values.netpol.ingress).allowedNamespaceMatchLabels }}
- namespaceSelector:
matchLabels:
name: {{ $ns | required "netpol.ingress.allowedNamespaceMatchLabels must be valid" }}
{{- end }}
{{- range $ns := (.Values.netpol.ingress).allowedPodMatchLabels }}
- podSelector:
matchLabels:
name: {{ $ns | required "netpol.ingress.allowedPodMatchLabels must be valid" }}
{{- end }}
policyTypes:
- Ingress
{{ end }}
6 changes: 4 additions & 2 deletions charts/oneShotMetricsServer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ service:

netpol:
generate: true
from:

ingress:
allowedNamespaceMatchLabels: []
allowedPodMatchLabels: []

0 comments on commit b7f200a

Please sign in to comment.