Skip to content
Snippets Groups Projects
Commit 1a964fd2 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-3880 - add network policy' (#71) from OZG-3880-network-policies into master

parents 7d2b587f 9e1626e4
Branches
Tags
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
...@@ -35,6 +35,7 @@ app.kubernetes.io/part-of: kop ...@@ -35,6 +35,7 @@ app.kubernetes.io/part-of: kop
app.kubernetes.io/version: {{ include "app.version" . }} app.kubernetes.io/version: {{ include "app.version" . }}
app.kubernetes.io/namespace: {{ include "app.namespace" . }} app.kubernetes.io/namespace: {{ include "app.namespace" . }}
helm.sh/chart: {{ include "app.chart" . }} helm.sh/chart: {{ include "app.chart" . }}
ozg-component: eingangsadapter
{{- end -}} {{- end -}}
{{- define "app.matchLabels" }} {{- define "app.matchLabels" }}
......
#
# 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.
#
{{- if not (.Values.networkPolicy).disabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: network-policy-{{ include "app.name" .}}
namespace: {{ .Release.Namespace }}
spec:
podSelector:
matchLabels:
ozg-component: eingangsadapter
policyTypes:
- Ingress
- Egress
ingress:
- ports:
- port: 8080
egress:
- to:
- podSelector:
matchLabels:
component: pluto
ports:
- port: 9090
protocol: TCP
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
{{- end }}
\ No newline at end of file
...@@ -44,3 +44,9 @@ tests: ...@@ -44,3 +44,9 @@ tests:
- equal: - equal:
path: spec.template.spec.containers[0].image path: spec.template.spec.containers[0].image
value: docker.ozg-sh.de/intelliform-adapter:latest value: docker.ozg-sh.de/intelliform-adapter:latest
- it: should have label ozg-component
asserts:
- equal:
path: metadata.labels.ozg-component
value: eingangsadapter
#
# 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 test
release:
name: afm-adapter
namespace: by-helm-test
templates:
- templates/network_policy.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-afm-adapter
namespace: by-helm-test
- it: validate spec
asserts:
- equal:
path: spec
value:
podSelector:
matchLabels:
ozg-component: eingangsadapter
policyTypes:
- Ingress
- Egress
ingress:
- ports:
- port: 8080
egress:
- to:
- podSelector:
matchLabels:
component: pluto
ports:
- port: 9090
protocol: TCP
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
- it: test network policy disabled
set:
networkPolicy:
disabled: true
asserts:
- hasDocuments:
count: 0
- it: test network policy unset should be disabled
set:
networkPolicy:
disabled: false
asserts:
- hasDocuments:
count: 1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment