diff --git a/Makefile b/Makefile index 1b4e5a0..18f08e4 100644 --- a/Makefile +++ b/Makefile @@ -38,9 +38,8 @@ $(IMAGE_LIST): # Create tgz of the chart .PHONY: charts -charts: clean - $(HELM) dep up charts/maas - $(HELM) package charts/maas +charts: helm_lint + $(HELM) package build/charts/maas # Perform Linting .PHONY: lint @@ -48,9 +47,9 @@ lint: helm_lint # Dry run templating of chart .PHONY: dry-run -dry-run: clean +dry-run: helm_lint tools/helm_tk.sh $(HELM) - $(HELM) template charts/maas + $(HELM) template build/charts/maas # Make targets intended for use by the primary targets above. @@ -69,4 +68,7 @@ clean: .PHONY: helm_lint helm_lint: clean tools/helm_tk.sh $(HELM) - $(HELM) lint charts/maas + mkdir -p build/charts/maas + cp -R charts/maas build/charts/ + $(HELM) dep up build/charts/maas + $(HELM) lint build/charts/maas diff --git a/charts/maas/templates/bin/_maas-test.sh.tpl b/charts/maas/templates/bin/_maas-test.sh.tpl new file mode 100644 index 0000000..4634355 --- /dev/null +++ b/charts/maas/templates/bin/_maas-test.sh.tpl @@ -0,0 +1,20 @@ +#!/bin/bash +{{/* +# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. */}} + +set -ex + +maas login local ${MAAS_URL} $MAAS_API_KEY +echo $? diff --git a/charts/maas/templates/configmap-bin.yaml b/charts/maas/templates/configmap-bin.yaml index 9648e3a..f448d5e 100644 --- a/charts/maas/templates/configmap-bin.yaml +++ b/charts/maas/templates/configmap-bin.yaml @@ -37,3 +37,5 @@ data: {{ tuple "bin/_export-api-key.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} register-rack-controller.sh: | {{ tuple "bin/_register-rack-controller.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + maas-test.sh: | +{{ tuple "bin/_maas-test.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} diff --git a/charts/maas/templates/deployment-rack.yaml b/charts/maas/templates/deployment-rack.yaml index 4e7f837..f888007 100644 --- a/charts/maas/templates/deployment-rack.yaml +++ b/charts/maas/templates/deployment-rack.yaml @@ -45,7 +45,7 @@ spec: hostNetwork: true dnsPolicy: ClusterFirst initContainers: -{{ tuple $envAll $dependencies "[]" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - name: maas-rack image: {{ .Values.images.tags.maas_rack }} diff --git a/charts/maas/templates/job-bootstrap-admin-user.yaml b/charts/maas/templates/job-bootstrap-admin-user.yaml index fff82f8..8111784 100644 --- a/charts/maas/templates/job-bootstrap-admin-user.yaml +++ b/charts/maas/templates/job-bootstrap-admin-user.yaml @@ -31,7 +31,7 @@ spec: nodeSelector: {{ .Values.labels.region.node_selector_key }}: {{ .Values.labels.region.node_selector_value }} initContainers: -{{ tuple $envAll $dependencies "[]" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - name: maas-bootstrap-admin-user image: {{ .Values.images.tags.bootstrap }} diff --git a/charts/maas/templates/job-db-init.yaml b/charts/maas/templates/job-db-init.yaml index 4672e44..a38008e 100644 --- a/charts/maas/templates/job-db-init.yaml +++ b/charts/maas/templates/job-db-init.yaml @@ -31,7 +31,7 @@ spec: nodeSelector: {{ .Values.labels.region.node_selector_key }}: {{ .Values.labels.region.node_selector_value }} initContainers: -{{ tuple $envAll $dependencies "[]" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - name: maas-db-init image: {{ .Values.images.tags.db_init | quote }} diff --git a/charts/maas/templates/job-db-sync.yaml b/charts/maas/templates/job-db-sync.yaml index f7adc32..13c66e8 100644 --- a/charts/maas/templates/job-db-sync.yaml +++ b/charts/maas/templates/job-db-sync.yaml @@ -31,7 +31,7 @@ spec: nodeSelector: {{ .Values.labels.region.node_selector_key }}: {{ .Values.labels.region.node_selector_value }} initContainers: -{{ tuple $envAll $dependencies "[]" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - name: maas-db-sync image: {{ .Values.images.tags.db_sync }} diff --git a/charts/maas/templates/job-import.yaml b/charts/maas/templates/job-import.yaml index 39c5e71..4fb6ffb 100644 --- a/charts/maas/templates/job-import.yaml +++ b/charts/maas/templates/job-import.yaml @@ -31,7 +31,7 @@ spec: nodeSelector: {{ .Values.labels.region.node_selector_key }}: {{ .Values.labels.region.node_selector_value }} initContainers: -{{ tuple $envAll $dependencies "[]" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - name: region-import-resources image: {{ .Values.images.tags.maas_region }} diff --git a/charts/maas/templates/tests/test-maas-api.yaml b/charts/maas/templates/tests/test-maas-api.yaml new file mode 100644 index 0000000..2218890 --- /dev/null +++ b/charts/maas/templates/tests/test-maas-api.yaml @@ -0,0 +1,52 @@ +{{/* +# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. */}} +{{/* +Test that the API is up and can be logged into */}} +{{- if .Values.manifests.test_maas_api }} +--- +apiVersion: v1 +kind: Pod +metadata: + name: "{{ .Release.Name }}-api-test" + annotations: + "helm.sh/hook": "test-success" +spec: + restartPolicy: Never + containers: + - name: "{{ .Release.Name }}-api-test" + env: + - name: 'MAAS_URL' + value: {{ tuple "maas_region_ui" "internal" "region_ui" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | quote }} + - name: 'MAAS_API_KEY' + valueFrom: + secretKeyRef: + name: 'maas-api-key' + key: 'token' + image: {{ .Values.images.tags.maas_region }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple . .Values.pod.resources.test | include "helm-toolkit.snippets.kubernetes_resources" | indent 8 }} + command: ["/tmp/maas-test.sh"] + volumeMounts: + - name: maas-bin + mountPath: /tmp/maas-test.sh + subPath: maas-test.sh + readOnly: true + volumes: + - name: maas-bin + configMap: + name: maas-bin + defaultMode: 0555 +... +{{- end }} diff --git a/charts/maas/values.yaml b/charts/maas/values.yaml index ad8693b..9f3f68e 100644 --- a/charts/maas/values.yaml +++ b/charts/maas/values.yaml @@ -64,6 +64,7 @@ dependencies: manifests: region_statefulset: true rack_deployment: true + test_maas_api: true images: tags: @@ -118,7 +119,7 @@ conf: drydock: bootaction_url: null cache: - enabled: true + enabled: false maas: override: append: @@ -169,13 +170,13 @@ pod: default: kubernetes.io/hostname mounts: maas_rack: - init_container: null + init_container: [] maas_rack: maas_region: - init_container: null + init_container: [] maas_region: export_api_key: - init_container: null + init_container: [] export_api_key: replicas: rack: 1 diff --git a/tools/helm_tk.sh b/tools/helm_tk.sh index 867cdce..fc03425 100755 --- a/tools/helm_tk.sh +++ b/tools/helm_tk.sh @@ -59,7 +59,3 @@ git pull helm_serve make helm-toolkit popd && popd -for c in $DEP_UP_LIST -do - ${HELM} dep up charts/$c -done