From bfa237d34733cc23baa5d1966e4caf610fd5b09f Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Tue, 9 Oct 2018 09:49:18 -0500 Subject: [PATCH] Charts: Update helm test pod templates This updates the helm test pod templates in the charts with helm tests defined. This change includes the addition of: - Generate test pod cluster roles and role bindings - Generate service accounts for test pods - Add node selectors to the test pods - Add service accounts to the test pods - Addition of entrypoint container to the test pods - Indentation fix for rabbitmq test pod template Change-Id: I9a0dd8a1a87bfe5eaf1362e92b37bc004f9c2cdb --- elasticsearch/templates/pod-helm-tests.yaml | 8 ++++++++ elasticsearch/values.yaml | 7 +++++++ fluent-logging/templates/pod-helm-tests.yaml | 8 ++++++++ fluent-logging/values.yaml | 3 +++ grafana/templates/pod-helm-tests.yaml | 8 ++++++++ grafana/values.yaml | 3 +++ prometheus/templates/pod-helm-tests.yaml | 8 ++++++++ prometheus/values.yaml | 7 +++++++ rabbitmq/templates/pod-test.yaml | 2 +- 9 files changed, 53 insertions(+), 1 deletion(-) diff --git a/elasticsearch/templates/pod-helm-tests.yaml b/elasticsearch/templates/pod-helm-tests.yaml index 3a6164a72..442c87913 100644 --- a/elasticsearch/templates/pod-helm-tests.yaml +++ b/elasticsearch/templates/pod-helm-tests.yaml @@ -17,6 +17,9 @@ limitations under the License. {{- if .Values.manifests.helm_tests }} {{- $envAll := . }} {{- $esUserSecret := .Values.secrets.elasticsearch.user }} + +{{- $serviceAccountName := print .Release.Name "-test" }} +{{ tuple $envAll "tests" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: v1 kind: Pod @@ -28,7 +31,12 @@ metadata: "helm.sh/hook": test-success {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} spec: + serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }} restartPolicy: Never + initContainers: +{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - name: {{.Release.Name}}-helm-tests {{ tuple $envAll "helm_tests" | include "helm-toolkit.snippets.image" | indent 6 }} diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 49a12ece2..e6682eda2 100644 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -44,6 +44,9 @@ labels: job: node_selector_key: openstack-control-plane node_selector_value: enabled + test: + node_selector_key: openstack-control-plane + node_selector_value: enabled dependencies: dynamic: @@ -89,6 +92,10 @@ dependencies: s3_bucket: jobs: - elasticsearch-s3-user + tests: + services: + - endpoint: internal + service: elasticsearch pod: affinity: diff --git a/fluent-logging/templates/pod-helm-tests.yaml b/fluent-logging/templates/pod-helm-tests.yaml index 0df1495cf..6d762d57b 100644 --- a/fluent-logging/templates/pod-helm-tests.yaml +++ b/fluent-logging/templates/pod-helm-tests.yaml @@ -17,6 +17,9 @@ limitations under the License. {{- if .Values.manifests.helm_tests }} {{- $envAll := . }} {{- $esUserSecret := .Values.secrets.elasticsearch.user }} + +{{- $serviceAccountName := print .Release.Name "-test" }} +{{ tuple $envAll "tests" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: v1 kind: Pod @@ -28,7 +31,12 @@ metadata: "helm.sh/hook": test-success {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} spec: + serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }} restartPolicy: Never + initContainers: +{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - name: {{.Release.Name}}-helm-tests {{ tuple $envAll "helm_tests" | include "helm-toolkit.snippets.image" | indent 6 }} diff --git a/fluent-logging/values.yaml b/fluent-logging/values.yaml index 8f728f442..5b1c2816a 100644 --- a/fluent-logging/values.yaml +++ b/fluent-logging/values.yaml @@ -33,6 +33,9 @@ labels: job: node_selector_key: openstack-control-plane node_selector_value: enabled + test: + node_selector_key: openstack-control-plane + node_selector_value: enabled images: tags: diff --git a/grafana/templates/pod-helm-tests.yaml b/grafana/templates/pod-helm-tests.yaml index a61befe41..b887b1fef 100644 --- a/grafana/templates/pod-helm-tests.yaml +++ b/grafana/templates/pod-helm-tests.yaml @@ -17,6 +17,9 @@ limitations under the License. {{- if .Values.manifests.helm_tests }} {{- $dashboardCount := len .Values.conf.dashboards }} {{- $envAll := . }} + +{{- $serviceAccountName := print .Release.Name "-test" }} +{{ tuple $envAll "tests" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: v1 kind: Pod @@ -28,7 +31,12 @@ metadata: "helm.sh/hook": test-success {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} spec: + serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }} restartPolicy: Never + initContainers: +{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - name: {{.Release.Name}}-helm-tests {{ tuple $envAll "helm_tests" | include "helm-toolkit.snippets.image" | indent 6 }} diff --git a/grafana/values.yaml b/grafana/values.yaml index ba95c92b7..2c0bcf726 100644 --- a/grafana/values.yaml +++ b/grafana/values.yaml @@ -38,6 +38,9 @@ labels: job: node_selector_key: openstack-control-plane node_selector_value: enabled + test: + node_selector_key: openstack-control-plane + node_selector_value: enabled pod: affinity: diff --git a/prometheus/templates/pod-helm-tests.yaml b/prometheus/templates/pod-helm-tests.yaml index f19c2a2e5..4db6b2283 100644 --- a/prometheus/templates/pod-helm-tests.yaml +++ b/prometheus/templates/pod-helm-tests.yaml @@ -17,6 +17,9 @@ limitations under the License. {{- if .Values.manifests.helm_tests }} {{- $envAll := . }} {{- $promUserSecret := .Values.secrets.prometheus.admin }} + +{{- $serviceAccountName := print .Release.Name "-test" }} +{{ tuple $envAll "tests" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: v1 kind: Pod @@ -28,7 +31,12 @@ metadata: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} "helm.sh/hook": test-success spec: + serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }} restartPolicy: Never + initContainers: +{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - name: {{.Release.Name}}-helm-tests {{ tuple $envAll "helm_tests" | include "helm-toolkit.snippets.image" | indent 6 }} diff --git a/prometheus/values.yaml b/prometheus/values.yaml index 0c7566e1e..09b2fa0ff 100644 --- a/prometheus/values.yaml +++ b/prometheus/values.yaml @@ -38,6 +38,9 @@ labels: job: node_selector_key: openstack-control-plane node_selector_value: enabled + test: + node_selector_key: openstack-control-plane + node_selector_value: enabled pod: affinity: @@ -181,6 +184,10 @@ dependencies: service: local_image_registry prometheus: services: null + tests: + services: + - endpoint: internal + service: monitoring monitoring: prometheus: diff --git a/rabbitmq/templates/pod-test.yaml b/rabbitmq/templates/pod-test.yaml index 46d45ab6a..5fdc01eb5 100644 --- a/rabbitmq/templates/pod-test.yaml +++ b/rabbitmq/templates/pod-test.yaml @@ -35,7 +35,7 @@ spec: {{ $envAll.Values.labels.test.node_selector_key }}: {{ $envAll.Values.labels.test.node_selector_value | quote }} restartPolicy: Never initContainers: -{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - name: {{.Release.Name}}-rabbitmq-test {{ tuple $envAll "scripted_test" | include "helm-toolkit.snippets.image" | indent 6 }}