diff --git a/src/main/helm/templates/network_policy.yaml b/src/main/helm/templates/network_policy.yaml index e5dc19013b7951904275b9b9f46f66df151cfbcf..ce4d6d32503339499c8aa2f171dd809cd5613ef4 100644 --- a/src/main/helm/templates/network_policy.yaml +++ b/src/main/helm/templates/network_policy.yaml @@ -14,10 +14,9 @@ spec: ingress: - ports: - port: 8080 - {{- with (.Values.networkPolicy).additionalIngressConfig }} - - from: -{{ toYaml . | indent 8 }} - {{- end }} +{{- with (.Values.networkPolicy).additionalIngressConfig }} +{{ toYaml . | indent 2 }} +{{- end }} egress: - to: - podSelector: @@ -43,4 +42,15 @@ spec: protocol: UDP - port: 5353 protocol: TCP + - to: + - podSelector: + matchLabels: + component: user-manager + ports: + - port: 9000 + protocol: TCP +{{- with (.Values.networkPolicy).additionalEgressConfig }} +{{ toYaml . | indent 2 }} +{{- end }} + {{- end }} \ No newline at end of file diff --git a/src/test/helm/network_policy_test.yaml b/src/test/helm/network_policy_test.yaml index 48ff2afe0c20aafdfba64aa464173ee75711db37..31383e6c2292aca35cae21bd543f7b9a506dfe23 100644 --- a/src/test/helm/network_policy_test.yaml +++ b/src/test/helm/network_policy_test.yaml @@ -91,25 +91,50 @@ tests: protocol: UDP - port: 5353 protocol: TCP + - to: + - podSelector: + matchLabels: + component: user-manager + ports: + - port: 9000 + protocol: TCP + - it: add ingress rule by values set: networkPolicy: - ssoPublicIp: 1.1.1.1 - dnsServerNamespace: kube-system + 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: