Skip to content
Snippets Groups Projects
Commit 120a78e9 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3880 - add network policy

parent 094d320b
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
set -e
helm template ./src/main/helm/ -f src/test/unit-values.yaml
helm lint -f src/test/unit-values.yaml ./src/main/helm/
cd src/main/helm && helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' .
\ No newline at end of file
{{- if not (.Values.network_policy).disabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: network-policy-alfa
namespace: {{ .Release.Namespace }}
spec:
podSelector:
matchLabels:
component: goofy
policyTypes:
- Ingress
- Egress
ingress:
- ports:
- port: 8080
{{- with (.Values.network_policy).additional_ingress_config }}
- from:
{{ toYaml . | indent 8 }}
{{- end }}
egress:
- to:
- podSelector:
matchLabels:
component: pluto
ports:
- port: 9090
protocol: TCP
# public keycloak ip
- to:
- ipBlock:
cidr: {{ required "Keycloak public IP must be set" (.Values.network_policy).sso_public_ip }}
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- kube-system
ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
{{- end }}
\ No newline at end of file
#
# Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den
# Ministerpräsidenten des Landes Schleswig-Holstein
# Staatskanzlei
# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
#
# Lizenziert unter der EUPL, Version 1.2 oder - sobald
# diese von der Europäischen Kommission genehmigt wurden -
# Folgeversionen der EUPL ("Lizenz");
# Sie dürfen dieses Werk ausschließlich gemäß
# dieser Lizenz nutzen.
# Eine Kopie der Lizenz finden Sie hier:
#
# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
#
# Sofern nicht durch anwendbare Rechtsvorschriften
# gefordert oder in schriftlicher Form vereinbart, wird
# die unter der Lizenz verbreitete Software "so wie sie
# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
# ausdrücklich oder stillschweigend - verbreitet.
# Die sprachspezifischen Genehmigungen und Beschränkungen
# unter der Lizenz sind dem Lizenztext zu entnehmen.
#
suite: network policy alfa test
release:
name: alfa
namespace: by-helm-test
templates:
- templates/network_policy_alfa.yaml
tests:
- it: should match apiVersion
asserts:
- isAPIVersion:
of: networking.k8s.io/v1
- it: should match kind
asserts:
- isKind:
of: NetworkPolicy
- it: validate metadata
asserts:
- equal:
path: metadata
value:
name: network-policy-alfa
namespace: by-helm-test
- it: validate spec
asserts:
- equal:
path: spec
value:
podSelector:
matchLabels:
component: goofy
policyTypes:
- Ingress
- Egress
ingress:
- ports:
- port: 8080
egress:
- to:
- podSelector:
matchLabels:
component: pluto
ports:
- port: 9090
protocol: TCP
# public keycloak ip
- to:
- ipBlock:
cidr: 51.89.117.53/32
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- kube-system
ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
- it: add ingress rule by values
set:
network_policy:
additional_ingress_config:
- podSelector:
matchLabels:
component: client2
asserts:
- equal:
path: spec.ingress
value:
- ports:
- port: 8080
- from:
- podSelector:
matchLabels:
component: client2
- it: test network policy disabled
set:
network_policy:
disabled: true
asserts:
- hasDocuments:
count: 0
- it: test network policy unset should be disabled
set:
network_policy:
disabled: false
asserts:
- hasDocuments:
count: 1
\ No newline at end of file
......@@ -42,3 +42,7 @@ baseUrl: test.sh.ozg-cloud.de
image:
path: docker.ozg-sh.de/goofy
tag: snapshot-latest
network_policy:
sso_public_ip: 51.89.117.53/32
additional_ingress_config:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment