From 2b14ef174b44a7c6e591d84d025f165d907ed9c6 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 21 Dec 2023 14:33:19 +0100 Subject: [PATCH] OZG-4453 add certificate mounts --- .../templates/configmap_bindings_type.yaml | 32 +++++++++++++ .../src/main/helm/templates/deployment.yaml | 9 ++++ .../helm/configmap_bindings_type_test.yaml | 45 ++++++++++++++++++ .../src/test/helm/deployment_volumes.yaml | 47 ++++++++++++++++--- .../src/test/helm/linter_values.yaml | 7 ++- 5 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 ozgcloud-elasticsearch-operator/src/main/helm/templates/configmap_bindings_type.yaml create mode 100644 ozgcloud-elasticsearch-operator/src/test/helm/configmap_bindings_type_test.yaml diff --git a/ozgcloud-elasticsearch-operator/src/main/helm/templates/configmap_bindings_type.yaml b/ozgcloud-elasticsearch-operator/src/main/helm/templates/configmap_bindings_type.yaml new file mode 100644 index 0000000..d2ec843 --- /dev/null +++ b/ozgcloud-elasticsearch-operator/src/main/helm/templates/configmap_bindings_type.yaml @@ -0,0 +1,32 @@ +# +# Copyright (C) 2023 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. +# + +apiVersion: v1 +kind: ConfigMap +metadata: + name: bindings-type + namespace: {{ .Release.Namespace }} +data: + type: | + ca-certificates \ No newline at end of file diff --git a/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml b/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml index 339d684..b2c1e68 100644 --- a/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml +++ b/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml @@ -52,6 +52,8 @@ spec: {{- with (.Values.env).customList }} {{ toYaml . | indent 8 }} {{- end }} + - name: SERVICE_BINDING_ROOT + value: "/bindings" imagePullPolicy: Always readinessProbe: failureThreshold: 3 @@ -86,11 +88,18 @@ spec: terminationMessagePolicy: File tty: true volumeMounts: + - name: bindings + mountPath: "/bindings/ca-certificates/type" + subPath: type + readOnly: true - name: elasticsearch-certificate mountPath: "/bindings/ca-certificates/elasticsearch-certificate.pem" subPath: ca.crt readOnly: true volumes: + - name: bindings + configMap: + name: bindings-type - name: elasticsearch-certificate secret: secretName: elasticsearch-certificate diff --git a/ozgcloud-elasticsearch-operator/src/test/helm/configmap_bindings_type_test.yaml b/ozgcloud-elasticsearch-operator/src/test/helm/configmap_bindings_type_test.yaml new file mode 100644 index 0000000..83ece1c --- /dev/null +++ b/ozgcloud-elasticsearch-operator/src/test/helm/configmap_bindings_type_test.yaml @@ -0,0 +1,45 @@ +# +# 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: Certificate ConfigMap Binding +release: + namespace: sh-helm-test +templates: + - templates/configmap_bindings_type.yaml +tests: + - it: validate configMap values + asserts: + - isKind: + of: ConfigMap + - equal: + path: metadata.name + value: bindings-type + - equal: + path: metadata.namespace + value: sh-helm-test + - equal: + path: data + value: + type: | + ca-certificates \ No newline at end of file diff --git a/ozgcloud-elasticsearch-operator/src/test/helm/deployment_volumes.yaml b/ozgcloud-elasticsearch-operator/src/test/helm/deployment_volumes.yaml index 4598337..b5051b2 100644 --- a/ozgcloud-elasticsearch-operator/src/test/helm/deployment_volumes.yaml +++ b/ozgcloud-elasticsearch-operator/src/test/helm/deployment_volumes.yaml @@ -29,25 +29,58 @@ release: templates: - deployment.yaml tests: - - it: validate template type and api Version + - it: should create SERVICE_BINDING_ROOT set: image: name: hase tag: latest imagePullSecret: imagePullSecret asserts: - - equal: + - contains: + path: spec.template.spec.containers[0].env + content: + name: SERVICE_BINDING_ROOT + value: "/bindings" + + - it: should create volumes + set: + image: + name: hase + tag: latest + imagePullSecret: imagePullSecret + asserts: + - contains: + path: spec.template.spec.volumes + content: + name: bindings + configMap: + name: bindings-type + - contains: path: spec.template.spec.volumes - value: - - name: elasticsearch-certificate + content: + name: elasticsearch-certificate secret: secretName: elasticsearch-certificate optional: false - - equal: + - it: should create volumeMounts + set: + image: + name: hase + tag: latest + imagePullSecret: imagePullSecret + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: bindings + mountPath: "/bindings/ca-certificates/type" + subPath: type + readOnly: true + - contains: path: spec.template.spec.containers[0].volumeMounts - value: - - name: elasticsearch-certificate + content: + name: elasticsearch-certificate mountPath: "/bindings/ca-certificates/elasticsearch-certificate.pem" subPath: ca.crt readOnly: true \ No newline at end of file diff --git a/ozgcloud-elasticsearch-operator/src/test/helm/linter_values.yaml b/ozgcloud-elasticsearch-operator/src/test/helm/linter_values.yaml index 26396d4..aab55ac 100644 --- a/ozgcloud-elasticsearch-operator/src/test/helm/linter_values.yaml +++ b/ozgcloud-elasticsearch-operator/src/test/helm/linter_values.yaml @@ -3,4 +3,9 @@ image: name: test tag: latest -imagePullSecret: "docker-secret" \ No newline at end of file +imagePullSecret: "docker-secret" + +env: + customList: + - name: my_test_environment_name + value: "A test value" \ No newline at end of file -- GitLab