Skip to content

Commit

Permalink
feat: whitelist all ingress traffic if team network policies are disa… (
Browse files Browse the repository at this point in the history
  • Loading branch information
j-zimnowoda authored Feb 29, 2024
1 parent 0e52f19 commit 6b4d70d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion charts/team-ns/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
{{- $v := .Values | merge (dict) }}
{{- $prometheus := dig "managedMonitoring" "prometheus" false $v }}
{{- $alertmng := dig "managedMonitoring" "alertmanager" false $v }}
{{- if and (not (eq $v.teamId "admin")) (dig "networkPolicy" "ingressPrivate" true $v) }}
{{- if (not (dig "networkPolicy" "ingressPrivate" true $v)) }}
---
# If team network policies are disabled then we whitelist all traffic to prevent undesired blocking while deploying team workloads
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: default-ingress-allow-all
labels: {{- include "team-ns.chart-labels" $ | nindent 4 }}
spec:
podSelector:
matchLabels: {}
ingress:
- from:
- namespaceSelector: {}
{{- else if and (not (eq $v.teamId "admin")) (dig "networkPolicy" "ingressPrivate" true $v) }}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/env/teams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ teamConfig:
prometheus: true
networkPolicy:
egressPublic: true
ingressPrivate: true
ingressPrivate: false
oidc:
groupMapping: somesecretvalue
resourceQuota:
Expand Down

0 comments on commit 6b4d70d

Please sign in to comment.