diff --git a/src/main/helm/templates/network_policy.yaml b/src/main/helm/templates/network_policy.yaml index 63f1e6467b9d531744bba9836e0d4c0514022253..867dfcd8e3707f5022566f53ad03d15e61551067 100644 --- a/src/main/helm/templates/network_policy.yaml +++ b/src/main/helm/templates/network_policy.yaml @@ -37,10 +37,15 @@ spec: ingress: - ports: - port: 8080 - {{- with (.Values.networkPolicy).additionalIngressConfig }} - - from: -{{ toYaml . | indent 8 }} - {{- end }} + - ports: + - port: 9090 + from: + - podSelector: + matchLabels: + component: user-manager +{{- with (.Values.networkPolicy).additionalIngressConfig }} +{{ toYaml . | indent 2 }} +{{- end }} egress: - to: - podSelector: @@ -66,5 +71,9 @@ spec: protocol: UDP - port: 5353 protocol: TCP +{{- with (.Values.networkPolicy).additionalEgressConfig }} +{{ toYaml . | indent 2 }} +{{- end }} + {{- end }} diff --git a/src/test/helm/network_policy_test.yaml b/src/test/helm/network_policy_test.yaml index d28baa40bd5d5ece8227a6da45d20d76469cd4a1..180147c483020b6bddb9cef1e97993cc1cab5799 100644 --- a/src/test/helm/network_policy_test.yaml +++ b/src/test/helm/network_policy_test.yaml @@ -61,6 +61,12 @@ tests: ingress: - ports: - port: 8080 + - ports: + - port: 9090 + from: + - podSelector: + matchLabels: + component: user-manager egress: - to: - podSelector: @@ -86,25 +92,42 @@ tests: protocol: UDP - port: 5353 protocol: TCP + - it: add ingress rule by values set: networkPolicy: ssoPublicIp: 51.89.117.53/32 dnsServerNamespace: test-namespace-dns additionalIngressConfig: - - podSelector: - matchLabels: - component: client2 + - from: + - podSelector: + matchLabels: + component: client2 asserts: - - equal: + - contains: path: spec.ingress - value: - - ports: - - port: 8080 - - from: - - podSelector: - matchLabels: - component: client2 + content: + from: + - podSelector: + matchLabels: + component: client2 + + - it: add egress rules by values + set: + networkPolicy: + ssoPublicIp: 51.89.117.53/32 + dnsServerNamespace: test-dns-namespace + additionalEgressConfig: + - to: + - ipBlock: + cidr: 1.2.3.4/32 + asserts: + - contains: + path: spec.egress + content: + to: + - ipBlock: + cidr: 1.2.3.4/32 - it: test network policy disabled set: @@ -114,7 +137,7 @@ tests: - hasDocuments: count: 0 - - it: test network policy unset should be disabled + - it: should generate network policies on disabled:false set: networkPolicy: disabled: false