Skip to content

Commit 1758b08

Browse files
authored
Merge pull request #17 from gitops-bridge-dev/teams-netpols
[feat] unique network policy names
2 parents 40daf29 + 27fa5f1 commit 1758b08

File tree

7 files changed

+12
-28
lines changed

7 files changed

+12
-28
lines changed

charts/teams/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: team
33
description: A Helm Chart to bootstrap a Namespace in a Multi-Tenancy setup
4-
version: 1.0.0
4+
version: 2.0.0
55
type: application
66

charts/teams/templates/_helpers.tpl

-22
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,3 @@ helm.sh/chart: {{ include "team.chart" . }}
5656
{{- end }}
5757
{{- end }}
5858

59-
60-
{{/*
61-
Create the name of the NetworkPolicy to deny all outgoing traffic
62-
*/}}
63-
{{- define "team.networkPolicy.egress.deny.all.name" }}
64-
{{- printf "%s-%s" ((include "team.fullname" .) | trunc 47 | trimSuffix "-") "egress-deny-all" }}
65-
{{- end }}
66-
67-
{{/*
68-
Create the name of the NetworkPolicy to allow outgoing traffic to the Kubernetes DNS
69-
*/}}
70-
{{- define "team.networkPolicy.egress.allow.dns.name" }}
71-
{{- printf "%s-%s" ((include "team.fullname" .) | trunc 47 | trimSuffix "-") "egress-allow-dns" }}
72-
{{- end }}
73-
74-
{{/*
75-
Create the name of the NetworkPolicy to deny all incoming traffic
76-
*/}}
77-
{{- define "team.networkPolicy.ingress.deny.all.name" }}
78-
{{- printf "%s-%s" ((include "team.fullname" .) | trunc 46 | trimSuffix "-") "ingress-deny-all" }}
79-
{{- end }}
80-

charts/teams/templates/networkpolicy/egress/allow-dns.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ metadata:
1818
{{- toYaml . | nindent 4 }}
1919
{{- end }}
2020
{{- end }}
21-
name: {{ include "team.networkPolicy.egress.allow.dns.name" $ | quote }}
21+
name: {{ $.Values.networkPolicies.egress.allow.dns.name }}
2222
namespace: {{ $name }}
2323
spec:
2424
{{- if $.Values.networkPolicies.egress.allow.dns.podSelector }}

charts/teams/templates/networkpolicy/egress/deny-all.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and (.Values.networkPolicies.enabled) (.Values.networkPolicies.egress.deny.all) }}
1+
{{- if and (.Values.networkPolicies.enabled) (.Values.networkPolicies.egress.deny.all.enabled) }}
22
{{- range $name, $tenant := .Values.namespaces }}
33
---
44
apiVersion: networking.k8s.io/v1
@@ -18,7 +18,7 @@ metadata:
1818
{{- toYaml . | nindent 4 }}
1919
{{- end }}
2020
{{- end }}
21-
name: {{ include "team.networkPolicy.egress.deny.all.name" $ | quote }}
21+
name: {{ $.Values.networkPolicies.egress.deny.all.name }}
2222
namespace: {{ $name }}
2323
spec:
2424
{{- if $.Values.networkPolicies.egress.deny.all.podSelector }}

charts/teams/templates/networkpolicy/ingress/deny-all.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and (.Values.networkPolicies.enabled) (.Values.networkPolicies.ingress.deny.all) }}
1+
{{- if and (.Values.networkPolicies.enabled) (.Values.networkPolicies.ingress.deny.all.enabled) }}
22
{{- range $name, $tenant := .Values.namespaces }}
33
---
44
apiVersion: networking.k8s.io/v1
@@ -18,7 +18,7 @@ metadata:
1818
{{- toYaml . | nindent 4 }}
1919
{{- end }}
2020
{{- end }}
21-
name: {{ include "team.networkPolicy.ingress.deny.all.name" $ | quote }}
21+
name: {{ $.Values.networkPolicies.ingress.deny.all.name }}
2222
namespace: {{ $name }}
2323
spec:
2424
{{- if $.Values.networkPolicies.ingress.deny.all.podSelector }}

charts/teams/values-test.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ networkPolicies:
1212
egress:
1313
deny:
1414
all:
15+
name: egress-deny-all
1516
# -- create a NetworkPolicy that denies all outgoing traffic
1617
enabled: true
1718
# -- define a PodSelector that should be used. Uses all Pods by default
1819
podSelector: {}
1920
allow:
2021
dns:
22+
name: egress-allow-dns
2123
# -- create a NetworkPolicy that allows outgoing traffic to the Kubernetes DNS
2224
enabled: true
2325
# -- The namespace where the Kubneretes DNS is running
@@ -30,6 +32,7 @@ networkPolicies:
3032
ingress:
3133
deny:
3234
all:
35+
name: ingress-deny-all
3336
# -- create a NetworkPolicy that denies all incoming traffic
3437
enabled: true
3538
# -- define a PodSelector that should be used. Uses all Pods by default

charts/teams/values.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ networkPolicies:
88
egress:
99
deny:
1010
all:
11+
name: egress-deny-all
1112
# -- create a NetworkPolicy that denies all outgoing traffic
1213
enabled: true
1314
# -- define a PodSelector that should be used. Uses all Pods by default
1415
podSelector: {}
1516
allow:
1617
dns:
18+
name: egress-allow-dns
1719
# -- create a NetworkPolicy that allows outgoing traffic to the Kubernetes DNS
1820
enabled: true
1921
# -- The namespace where the Kubneretes DNS is running
@@ -26,6 +28,7 @@ networkPolicies:
2628
ingress:
2729
deny:
2830
all:
31+
name: ingress-deny-all
2932
# -- create a NetworkPolicy that denies all incoming traffic
3033
enabled: true
3134
# -- define a PodSelector that should be used. Uses all Pods by default

0 commit comments

Comments
 (0)