fix(netpol): allows toggling the lockdown

This patch set allows disabling egress and ingress separately.

Signed-off-by: Tin Lam <t@lam.wtf>
Change-Id: I18250a009d62a05983e00db7b7309dd065b94069
This commit is contained in:
Tin Lam 2021-09-10 15:10:37 -05:00
parent b7b2048b35
commit 9061d08a5e
4 changed files with 21 additions and 3 deletions

View File

@ -16,6 +16,6 @@ appVersion: "1.0"
description: | description: |
A helm chart used to lockdown all ingress and egress for a namespace A helm chart used to lockdown all ingress and egress for a namespace
name: lockdown name: lockdown
version: 0.1.0 version: 0.1.1
home: https://kubernetes.io/docs/concepts/services-networking/network-policies/ home: https://kubernetes.io/docs/concepts/services-networking/network-policies/
... ...

View File

@ -11,6 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/}} */}}
{{- if or .Values.conf.ingress.disallowed .Values.conf.egress.disallowed }}
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: NetworkPolicy kind: NetworkPolicy
metadata: metadata:
@ -18,8 +19,17 @@ metadata:
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
spec: spec:
policyTypes: policyTypes:
- Egress {{- if .Values.conf.ingress.disallowed }}
- Ingress - Ingress
{{- end }}
{{- if .Values.conf.egress.disallowed }}
- Egress
{{- end }}
podSelector: {} podSelector: {}
egress: [] {{- if .Values.conf.ingress.disallowed }}
ingress: [] ingress: []
{{- end }}
{{- if .Values.conf.egress.disallowed }}
egress: []
{{- end }}
{{- end }}

View File

@ -1,3 +1,4 @@
---
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
@ -13,3 +14,9 @@
# Default values for lockdown chart. # Default values for lockdown chart.
# This is a YAML-formatted file. # This is a YAML-formatted file.
# Declare variables to be passed into your templates. # Declare variables to be passed into your templates.
conf:
ingress:
disallowed: true
egress:
disallowed: true
...

View File

@ -1,4 +1,5 @@
--- ---
lockdown: lockdown:
- 0.1.0 Initial Chart - 0.1.0 Initial Chart
- 0.1.1 Allows toggling
... ...