diff --git a/config/common-config.yaml b/config/common-config.yaml index 216a94ddbd..86a52545d7 100644 --- a/config/common-config.yaml +++ b/config/common-config.yaml @@ -1206,7 +1206,7 @@ networkPolicies: additional: "" # |- - # --- + # --- # apiVersion: networking.k8s.io/v1 # kind: NetworkPolicy # metadata: diff --git a/helmfile.d/charts/networkpolicy/generator/templates/additional-np.yaml b/helmfile.d/charts/networkpolicy/generator/templates/additional-np.yaml new file mode 100644 index 0000000000..62ef9848ad --- /dev/null +++ b/helmfile.d/charts/networkpolicy/generator/templates/additional-np.yaml @@ -0,0 +1,3 @@ +{{- with .Values.additional }} +{{- . }} +{{- end }} diff --git a/helmfile.d/charts/networkpolicy/generator/templates/networkpolicy.yaml b/helmfile.d/charts/networkpolicy/generator/templates/networkpolicy.yaml index 94ac0e5428..142851ccdb 100644 --- a/helmfile.d/charts/networkpolicy/generator/templates/networkpolicy.yaml +++ b/helmfile.d/charts/networkpolicy/generator/templates/networkpolicy.yaml @@ -10,9 +10,13 @@ metadata: namespace: {{ $namespace }} spec: podSelector: + {{- with $policy.podSelectorExpressions }} + matchExpressions: {{- toYaml . | nindent 6 }} + {{- end }} {{- with $policy.podSelectorLabels }} matchLabels: {{- toYaml . | nindent 6 }} - {{- else }} {} {{- end }} + {{- end }} + {{- if not (or $policy.podSelectorLabels $policy.podSelectorExpressions) }} {} {{- end }} policyTypes: {{- if hasKey $policy "egress" }} - Egress diff --git a/helmfile.d/charts/networkpolicy/generator/values.yaml b/helmfile.d/charts/networkpolicy/generator/values.yaml index 0d34ef0a76..8497647166 100644 --- a/helmfile.d/charts/networkpolicy/generator/values.yaml +++ b/helmfile.d/charts/networkpolicy/generator/values.yaml @@ -122,3 +122,20 @@ policies: # - ports: # - tcp: 53 # - udp: 53 + +additional: {} +# |- +# apiVersion: networking.k8s.io/v1 +# kind: NetworkPolicy +# metadata: +# name: example-np +# namespace: default +# spec: +# policyTypes: +# - Ingress +# - Egress +# podSelector: +# matchLabels: +# foo: bar +# ingress: {} +# egress: {}