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

ozg-3322 use namespace truststore

parent 50e659e0
No related branches found
No related tags found
No related merge requests found
...@@ -146,3 +146,11 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} ...@@ -146,3 +146,11 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
{{- define "app.serviceAccountName" -}} {{- define "app.serviceAccountName" -}}
{{ printf "%s" ( (.Values.serviceAccount).name | default "user-manager-service-account" ) }} {{ printf "%s" ( (.Values.serviceAccount).name | default "user-manager-service-account" ) }}
{{- end -}} {{- end -}}
{{- define "app.truststoreSecretName" -}}
{{- if .Values.optionalTrustStoreSecretName -}}
{{ .Values.optionalTrustStoreSecretName }}
{{- else -}}
{{ printf "%s-truststore" .Release.Namespace }}
{{- end -}}
{{- end -}}
\ No newline at end of file
...@@ -116,16 +116,16 @@ spec: ...@@ -116,16 +116,16 @@ spec:
{{- with (.Values.env).customList }} {{- with (.Values.env).customList }}
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}
{{- if .Values.optionalTrustStoreSecretName }} {{- if not .Values.disableNamespaceTruststore }}
- name: TRUST_STORE_PASSWORD - name: TRUSTSTORE_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: {{ .Values.optionalTrustStoreSecretName }} name: {{ include "app.truststoreSecretName" . }}
key: password key: password
optional: false optional: false
args: args:
- '-Djavax.net.ssl.trustStore=/optional-trust-store/truststore.jks' - '-Djavax.net.ssl.trustStore=/namespace-truststore/truststore.jks'
- '-Djavax.net.ssl.trustStorePassword=$(TRUST_STORE_PASSWORD)' - '-Djavax.net.ssl.trustStorePassword=$(TRUSTSTORE_PASSWORD)'
{{- end }} {{- end }}
image: "{{ .Values.image.repo }}/{{ .Values.image.name }}:{{ coalesce (.Values.image).tag "latest" }}" image: "{{ .Values.image.repo }}/{{ .Values.image.name }}:{{ coalesce (.Values.image).tag "latest" }}"
imagePullPolicy: Always imagePullPolicy: Always
...@@ -191,7 +191,6 @@ spec: ...@@ -191,7 +191,6 @@ spec:
terminationMessagePath: /dev/termination-log terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File terminationMessagePolicy: File
tty: true tty: true
{{- if or (not .Values.disableGrpcServerTls) .Values.optionalTrustStoreSecretName }}
volumeMounts: volumeMounts:
{{- if not .Values.disableGrpcServerTls }} {{- if not .Values.disableGrpcServerTls }}
- name: user-manager-tls-certificate - name: user-manager-tls-certificate
...@@ -203,25 +202,21 @@ spec: ...@@ -203,25 +202,21 @@ spec:
subPath: tls.key subPath: tls.key
readOnly: true readOnly: true
{{- end }} {{- end }}
{{- if .Values.optionalTrustStoreSecretName }} {{- if not .Values.disableNamespaceTruststore }}
- name: optional-trust-store - name: namespace-truststore
mountPath: "/optional-trust-store/truststore.jks" mountPath: "/namespace-truststore"
subPath: truststore.jks
readOnly: true readOnly: true
{{- end }} {{- end }}
{{- end }}
{{- if or (not .Values.disableGrpcServerTls) .Values.optionalTrustStoreSecretName }}
volumes: volumes:
{{- if not .Values.disableGrpcServerTls }} {{- if not .Values.disableGrpcServerTls }}
- name: user-manager-tls-certificate - name: user-manager-tls-certificate
secret: secret:
secretName: user-manager-tls-cert secretName: user-manager-tls-cert
{{- end }} {{- end }}
{{- if .Values.optionalTrustStoreSecretName }} {{- if not .Values.disableNamespaceTruststore }}
- name: optional-trust-store - name: namespace-truststore
secret: secret:
secretName: {{ .Values.optionalTrustStoreSecretName }} secretName: {{ include "app.truststoreSecretName" . }}
{{- end }}
{{- end }} {{- end }}
dnsConfig: {} dnsConfig: {}
dnsPolicy: ClusterFirst dnsPolicy: ClusterFirst
......
...@@ -22,66 +22,98 @@ ...@@ -22,66 +22,98 @@
# unter der Lizenz sind dem Lizenztext zu entnehmen. # unter der Lizenz sind dem Lizenztext zu entnehmen.
# #
suite: test environments suite: test namespace truststore
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
release:
name: user-manager
namespace: by-helm-test
set: set:
ozgcloud: ozgcloud:
bundesland: by bundesland: by
bezeichner: helm bezeichner: helm
environment: dev environment: test
sso: sso:
serverUrl: sso.test.sh.ozg-cloud.de serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: check without truststore - it: check without truststore
set:
disableNamespaceTruststore: true
asserts: asserts:
- notExists: - notExists:
path: spec.template.spec.containers[0].args path: spec.template.spec.containers[0].args
- notContains: - notContains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: TRUST_STORE_PASSWORD name: TRUSTSTORE_PASSWORD
- notContains: - notContains:
path: spec.template.spec.containers[0].volumeMounts path: spec.template.spec.containers[0].volumeMounts
content: content:
name: optional-trust-store name: namespace-truststore
mountPath: "/optional-trust-store/truststore.jks" any: true
subPath: truststore.jks
readOnly: true
- notContains: - notContains:
path: spec.template.spec.volumes path: spec.template.spec.volumes
content: content:
name: optional-trust-store name: namespace-truststore
any: true
- it: check with default namespace truststore
asserts:
- equal:
path: spec.template.spec.containers[0].args
value:
- '-Djavax.net.ssl.trustStore=/namespace-truststore/truststore.jks'
- '-Djavax.net.ssl.trustStorePassword=$(TRUSTSTORE_PASSWORD)'
- contains:
path: spec.template.spec.containers[0].env
content:
name: TRUSTSTORE_PASSWORD
valueFrom:
secretKeyRef:
name: by-helm-test-truststore
key: password
optional: false
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: namespace-truststore
mountPath: "/namespace-truststore"
readOnly: true
- contains:
path: spec.template.spec.volumes
content:
name: namespace-truststore
secret:
secretName: by-helm-test-truststore
- it: check with truststore - it: check with optional truststore
set: set:
optionalTrustStoreSecretName: optional-trust-store-secret optionalTrustStoreSecretName: optional-truststore-secret
asserts: asserts:
- equal: - equal:
path: spec.template.spec.containers[0].args path: spec.template.spec.containers[0].args
value: value:
- '-Djavax.net.ssl.trustStore=/optional-trust-store/truststore.jks' - '-Djavax.net.ssl.trustStore=/namespace-truststore/truststore.jks'
- '-Djavax.net.ssl.trustStorePassword=$(TRUST_STORE_PASSWORD)' - '-Djavax.net.ssl.trustStorePassword=$(TRUSTSTORE_PASSWORD)'
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: TRUST_STORE_PASSWORD name: TRUSTSTORE_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: optional-trust-store-secret name: optional-truststore-secret
key: password key: password
optional: false optional: false
- contains: - contains:
path: spec.template.spec.containers[0].volumeMounts path: spec.template.spec.containers[0].volumeMounts
content: content:
name: optional-trust-store name: namespace-truststore
mountPath: "/optional-trust-store/truststore.jks" mountPath: "/namespace-truststore"
subPath: truststore.jks
readOnly: true readOnly: true
- contains: - contains:
path: spec.template.spec.volumes path: spec.template.spec.volumes
content: content:
name: optional-trust-store name: namespace-truststore
secret: secret:
secretName: optional-trust-store-secret secretName: optional-truststore-secret
\ No newline at end of file \ No newline at end of file
...@@ -81,13 +81,6 @@ tests: ...@@ -81,13 +81,6 @@ tests:
name: user-manager-tls-certificate name: user-manager-tls-certificate
any: true any: true
- it: should not have volume mounts
set:
disableGrpcServerTls: true
asserts:
- notExists:
path: spec.template.spec.containers[0].volumeMounts
- it: should not have volume for user-manager root certificate - it: should not have volume for user-manager root certificate
set: set:
disableGrpcServerTls: true disableGrpcServerTls: true
...@@ -96,10 +89,3 @@ tests: ...@@ -96,10 +89,3 @@ tests:
- notContains: - notContains:
path: spec.template.spec.volumes path: spec.template.spec.volumes
any: true any: true
- it: should not have volume
set:
disableGrpcServerTls: true
asserts:
- notExists:
path: spec.template.spec.volumes
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment