From f22f56964d02e6dbad1d0ae03009ada00c5eab05 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Sat, 21 Jan 2017 09:27:38 +0000 Subject: [PATCH 1/3] Update Endpoint Function to accomodate empty paths --- common/templates/_endpoints.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/templates/_endpoints.tpl b/common/templates/_endpoints.tpl index fe0a7d18..5237619c 100644 --- a/common/templates/_endpoints.tpl +++ b/common/templates/_endpoints.tpl @@ -107,8 +107,8 @@ {{- $endpointScheme := .scheme }} {{- $endpointHost := index .hosts $endpoint | default .hosts.default}} {{- $endpointPort := index .port $port }} -{{- $endpointPath := .path }} -{{- printf "%s://%s.%s:%1.f%s" $endpointScheme $endpointHost $fqdn $endpointPort $endpointPath | quote -}} +{{- $endpointPath := .path | default "" }} +{{- printf "%s://%s.%s:%1.f%s" $endpointScheme $endpointHost $fqdn $endpointPort $endpointPath -}} {{- end -}} {{- end -}} From a3208fd6318e49d6af81be055da044eaffc99f77 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Sat, 21 Jan 2017 00:48:57 +0000 Subject: [PATCH 2/3] Add daemonset support to Kubernetes Entrypoint This commit adds support for daemonsets to the Kubernetes-Entrypoint init-container. It also makes two other changes: * Moves the entrypoint container manifest snippet to its own file to reducle loading on the _funcs.tpl file * changes `dep-check-init-cont` to `dep_check_init_cont` to match the formatting of other defines used in OpenStack Helm --- cinder/templates/deployment-api.yaml | 2 +- cinder/templates/deployment-scheduler.yaml | 2 +- cinder/templates/deployment-volume.yaml | 2 +- cinder/templates/job-db-init.yaml | 2 +- cinder/templates/job-db-sync.yaml | 2 +- cinder/templates/job-ks-endpoints.yaml.yaml | 2 +- cinder/templates/job-ks-service.yaml | 2 +- cinder/templates/job-ks-user.yaml | 2 +- common/templates/_funcs.tpl | 32 ------------ .../snippets/_k8s_init_dep_check.tpl | 49 +++++++++++++++++++ glance/templates/deployment-api.yaml | 2 +- glance/templates/deployment-registry.yaml | 2 +- glance/templates/job-db-sync.yaml | 2 +- glance/templates/job-init.yaml | 2 +- glance/templates/job-post.yaml | 2 +- heat/templates/deployment-api.yaml | 2 +- heat/templates/deployment-cfn.yaml | 2 +- heat/templates/deployment-cloudwatch.yaml | 2 +- heat/templates/job-db-init.yaml | 2 +- heat/templates/job-db-sync.yaml | 2 +- heat/templates/job-ks-endpoints.yaml.yaml | 2 +- heat/templates/job-ks-service.yaml | 2 +- heat/templates/job-ks-user.yaml | 2 +- heat/templates/statefulset-engine.yaml | 2 +- horizon/templates/deployment.yaml | 2 +- keystone/templates/deployment.yaml | 2 +- keystone/templates/job-db-sync.yaml | 2 +- keystone/templates/job-init.yaml | 2 +- nova/templates/daemonset-compute.yaml | 2 +- nova/templates/daemonset-libvirt.yaml | 2 +- nova/templates/deployment-api-metadata.yaml | 2 +- nova/templates/deployment-api-osapi.yaml | 2 +- nova/templates/deployment-conductor.yaml | 2 +- nova/templates/deployment-consoleauth.yaml | 2 +- nova/templates/deployment-scheduler.yaml | 2 +- nova/templates/job-db-sync.yaml | 2 +- nova/templates/job-init.yaml | 2 +- nova/templates/job-post.yaml | 2 +- 38 files changed, 85 insertions(+), 68 deletions(-) create mode 100644 common/templates/snippets/_k8s_init_dep_check.tpl diff --git a/cinder/templates/deployment-api.yaml b/cinder/templates/deployment-api.yaml index b5a05f8f..cc3c3f6b 100644 --- a/cinder/templates/deployment-api.yaml +++ b/cinder/templates/deployment-api.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/cinder/templates/deployment-scheduler.yaml b/cinder/templates/deployment-scheduler.yaml index e18425e2..39663097 100644 --- a/cinder/templates/deployment-scheduler.yaml +++ b/cinder/templates/deployment-scheduler.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/cinder/templates/deployment-volume.yaml b/cinder/templates/deployment-volume.yaml index 1545b372..cb6c958c 100644 --- a/cinder/templates/deployment-volume.yaml +++ b/cinder/templates/deployment-volume.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/cinder/templates/job-db-init.yaml b/cinder/templates/job-db-init.yaml index f731d4fc..8c8338b0 100644 --- a/cinder/templates/job-db-init.yaml +++ b/cinder/templates/job-db-init.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/cinder/templates/job-db-sync.yaml b/cinder/templates/job-db-sync.yaml index f38c18cf..045f4622 100644 --- a/cinder/templates/job-db-sync.yaml +++ b/cinder/templates/job-db-sync.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/cinder/templates/job-ks-endpoints.yaml.yaml b/cinder/templates/job-ks-endpoints.yaml.yaml index 0d91fccf..455c0f34 100644 --- a/cinder/templates/job-ks-endpoints.yaml.yaml +++ b/cinder/templates/job-ks-endpoints.yaml.yaml @@ -10,7 +10,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/cinder/templates/job-ks-service.yaml b/cinder/templates/job-ks-service.yaml index 52585cf0..73934938 100644 --- a/cinder/templates/job-ks-service.yaml +++ b/cinder/templates/job-ks-service.yaml @@ -10,7 +10,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/cinder/templates/job-ks-user.yaml b/cinder/templates/job-ks-user.yaml index 9937ca26..49bc179a 100644 --- a/cinder/templates/job-ks-user.yaml +++ b/cinder/templates/job-ks-user.yaml @@ -11,7 +11,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/common/templates/_funcs.tpl b/common/templates/_funcs.tpl index 115892b1..fe6c9a67 100644 --- a/common/templates/_funcs.tpl +++ b/common/templates/_funcs.tpl @@ -21,35 +21,3 @@ {{- $wtf := $context.Template.Name | replace $last $name -}} {{- include $wtf $context | sha256sum | quote -}} {{- end -}} - -{{- define "dep-check-init-cont" -}} -{{- $envAll := index . 0 -}} -{{- $deps := index . 1 -}} -{ - "name": "init", - "image": {{ $envAll.Values.images.dep_check | quote }}, - "imagePullPolicy": {{ $envAll.Values.images.pull_policy | quote }}, - "env": [ - { - "name": "NAMESPACE", - "value": "{{ $envAll.Release.Namespace }}" - }, - { - "name": "INTERFACE_NAME", - "value": "eth0" - }, - { - "name": "DEPENDENCY_SERVICE", - "value": "{{ include "joinListWithColon" $deps.service }}" - }, - { - "name": "DEPENDENCY_JOBS", - "value": "{{ include "joinListWithColon" $deps.jobs }}" - }, - { - "name": "COMMAND", - "value": "echo done" - } - ] -} -{{- end -}} diff --git a/common/templates/snippets/_k8s_init_dep_check.tpl b/common/templates/snippets/_k8s_init_dep_check.tpl new file mode 100644 index 00000000..d55e0bc6 --- /dev/null +++ b/common/templates/snippets/_k8s_init_dep_check.tpl @@ -0,0 +1,49 @@ +{{- define "dep_check_init_cont" -}} +{{- $envAll := index . 0 -}} +{{- $deps := index . 1 -}} +{ + "name": "init", + "image": {{ $envAll.Values.images.dep_check | quote }}, + "imagePullPolicy": {{ $envAll.Values.images.pull_policy | quote }}, + "env": [ + { + "name": "POD_NAME", + "valueFrom": { + "fieldRef": { + "APIVersion": "v1", + "fieldPath": "metadata.name" + } + } + }, + { + "name": "NAMESPACE", + "valueFrom": { + "fieldRef": { + "APIVersion": "v1", + "fieldPath": "metadata.namespace" + } + } + }, + { + "name": "INTERFACE_NAME", + "value": "eth0" + }, + { + "name": "DEPENDENCY_SERVICE", + "value": "{{ include "joinListWithColon" $deps.service }}" + }, + { + "name": "DEPENDENCY_JOBS", + "value": "{{ include "joinListWithColon" $deps.jobs }}" + }, + { + "name": "DEPENDENCY_DAEMONSET", + "value": "{{ include "joinListWithColon" $deps.daemonset }}" + }, + { + "name": "COMMAND", + "value": "echo done" + } + ] +} +{{- end -}} diff --git a/glance/templates/deployment-api.yaml b/glance/templates/deployment-api.yaml index e4431c04..d998fb5d 100644 --- a/glance/templates/deployment-api.yaml +++ b/glance/templates/deployment-api.yaml @@ -26,7 +26,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/glance/templates/deployment-registry.yaml b/glance/templates/deployment-registry.yaml index 3df9090a..2d1f023b 100644 --- a/glance/templates/deployment-registry.yaml +++ b/glance/templates/deployment-registry.yaml @@ -18,7 +18,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/glance/templates/job-db-sync.yaml b/glance/templates/job-db-sync.yaml index 6cd0dd9b..3ecfb6af 100644 --- a/glance/templates/job-db-sync.yaml +++ b/glance/templates/job-db-sync.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/glance/templates/job-init.yaml b/glance/templates/job-init.yaml index 2fd28805..5bf5f063 100644 --- a/glance/templates/job-init.yaml +++ b/glance/templates/job-init.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/glance/templates/job-post.yaml b/glance/templates/job-post.yaml index da362afe..bbb53d76 100644 --- a/glance/templates/job-post.yaml +++ b/glance/templates/job-post.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/heat/templates/deployment-api.yaml b/heat/templates/deployment-api.yaml index 2b2d4d5b..25197f76 100755 --- a/heat/templates/deployment-api.yaml +++ b/heat/templates/deployment-api.yaml @@ -12,7 +12,7 @@ spec: app: heat-api annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/heat/templates/deployment-cfn.yaml b/heat/templates/deployment-cfn.yaml index d9035551..0cce31b8 100644 --- a/heat/templates/deployment-cfn.yaml +++ b/heat/templates/deployment-cfn.yaml @@ -12,7 +12,7 @@ spec: app: heat-cfn annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/heat/templates/deployment-cloudwatch.yaml b/heat/templates/deployment-cloudwatch.yaml index ccb66479..6f624a65 100644 --- a/heat/templates/deployment-cloudwatch.yaml +++ b/heat/templates/deployment-cloudwatch.yaml @@ -12,7 +12,7 @@ spec: app: heat-cloudwatch annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/heat/templates/job-db-init.yaml b/heat/templates/job-db-init.yaml index 6a7e343c..a98c571d 100644 --- a/heat/templates/job-db-init.yaml +++ b/heat/templates/job-db-init.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/heat/templates/job-db-sync.yaml b/heat/templates/job-db-sync.yaml index 4a9b004d..5f962a9d 100644 --- a/heat/templates/job-db-sync.yaml +++ b/heat/templates/job-db-sync.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/heat/templates/job-ks-endpoints.yaml.yaml b/heat/templates/job-ks-endpoints.yaml.yaml index e0a90d6a..6bfcfb70 100644 --- a/heat/templates/job-ks-endpoints.yaml.yaml +++ b/heat/templates/job-ks-endpoints.yaml.yaml @@ -10,7 +10,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/heat/templates/job-ks-service.yaml b/heat/templates/job-ks-service.yaml index 06738e16..8dba89f8 100644 --- a/heat/templates/job-ks-service.yaml +++ b/heat/templates/job-ks-service.yaml @@ -10,7 +10,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/heat/templates/job-ks-user.yaml b/heat/templates/job-ks-user.yaml index 27015404..7fd8f6d2 100644 --- a/heat/templates/job-ks-user.yaml +++ b/heat/templates/job-ks-user.yaml @@ -14,7 +14,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/heat/templates/statefulset-engine.yaml b/heat/templates/statefulset-engine.yaml index e494378c..0c5c8f00 100644 --- a/heat/templates/statefulset-engine.yaml +++ b/heat/templates/statefulset-engine.yaml @@ -13,7 +13,7 @@ spec: app: heat-engine annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/horizon/templates/deployment.yaml b/horizon/templates/deployment.yaml index 12fe7991..9d97e9cd 100644 --- a/horizon/templates/deployment.yaml +++ b/horizon/templates/deployment.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/keystone/templates/deployment.yaml b/keystone/templates/deployment.yaml index 54cff708..21321c99 100644 --- a/keystone/templates/deployment.yaml +++ b/keystone/templates/deployment.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependecies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependecies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/keystone/templates/job-db-sync.yaml b/keystone/templates/job-db-sync.yaml index e38bce91..d38bbc9e 100644 --- a/keystone/templates/job-db-sync.yaml +++ b/keystone/templates/job-db-sync.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependecies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependecies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/keystone/templates/job-init.yaml b/keystone/templates/job-init.yaml index be64047d..4e41f4ff 100644 --- a/keystone/templates/job-init.yaml +++ b/keystone/templates/job-init.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/nova/templates/daemonset-compute.yaml b/nova/templates/daemonset-compute.yaml index c40c3c5a..896739cf 100644 --- a/nova/templates/daemonset-compute.yaml +++ b/nova/templates/daemonset-compute.yaml @@ -13,7 +13,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/daemonset-libvirt.yaml b/nova/templates/daemonset-libvirt.yaml index 692728fa..bb461bc4 100644 --- a/nova/templates/daemonset-libvirt.yaml +++ b/nova/templates/daemonset-libvirt.yaml @@ -13,7 +13,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/deployment-api-metadata.yaml b/nova/templates/deployment-api-metadata.yaml index 8543f469..5ca429e8 100644 --- a/nova/templates/deployment-api-metadata.yaml +++ b/nova/templates/deployment-api-metadata.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/deployment-api-osapi.yaml b/nova/templates/deployment-api-osapi.yaml index a60c4d69..f0940a52 100644 --- a/nova/templates/deployment-api-osapi.yaml +++ b/nova/templates/deployment-api-osapi.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/deployment-conductor.yaml b/nova/templates/deployment-conductor.yaml index b52408ce..88798513 100644 --- a/nova/templates/deployment-conductor.yaml +++ b/nova/templates/deployment-conductor.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/deployment-consoleauth.yaml b/nova/templates/deployment-consoleauth.yaml index 6234e536..c62de255 100644 --- a/nova/templates/deployment-consoleauth.yaml +++ b/nova/templates/deployment-consoleauth.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/deployment-scheduler.yaml b/nova/templates/deployment-scheduler.yaml index 4db74f77..14f12e2c 100644 --- a/nova/templates/deployment-scheduler.yaml +++ b/nova/templates/deployment-scheduler.yaml @@ -22,7 +22,7 @@ spec: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }} pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: nodeSelector: diff --git a/nova/templates/job-db-sync.yaml b/nova/templates/job-db-sync.yaml index b8df59b6..94befb39 100644 --- a/nova/templates/job-db-sync.yaml +++ b/nova/templates/job-db-sync.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/nova/templates/job-init.yaml b/nova/templates/job-init.yaml index addc34d2..8db6c2b6 100644 --- a/nova/templates/job-init.yaml +++ b/nova/templates/job-init.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure diff --git a/nova/templates/job-post.yaml b/nova/templates/job-post.yaml index 4df83ae8..c91e7521 100644 --- a/nova/templates/job-post.yaml +++ b/nova/templates/job-post.yaml @@ -9,7 +9,7 @@ spec: metadata: annotations: pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep-check-init-cont" | indent 10 }} +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} ]' spec: restartPolicy: OnFailure From 12e13cea87af63933f7223bbc505c3e9ebe134b5 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Sat, 21 Jan 2017 09:33:16 +0000 Subject: [PATCH 3/3] Replace Ansible with OpenStack Client for Glance This commit removes the dependency on Ansible for the creation and management of Keystone Users and Endpoints. It makes use of the OpenStack Client which is part of the standard requirements for all OpenStack Services. The OpenStack Client is therefore included every OpenStack Service Container regardless of origin. --- glance/templates/bin/_post.sh.tpl | 42 ---------------- glance/templates/configmap-bin.yaml | 8 ++- glance/templates/etc/_glance-api.conf.tpl | 21 ++++---- .../templates/etc/_glance-registry.conf.tpl | 19 +++---- glance/templates/job-ks-endpoints.yaml.yaml | 50 +++++++++++++++++++ glance/templates/job-ks-service.yaml | 44 ++++++++++++++++ glance/templates/job-ks-user.yaml | 46 +++++++++++++++++ glance/templates/job-post.yaml | 35 ------------- .../templates/secret-keystone-admin.env.yaml | 20 ++++++++ .../templates/secret-keystone-user.env.yaml | 20 ++++++++ glance/values.yaml | 42 ++++++++++------ 11 files changed, 233 insertions(+), 114 deletions(-) delete mode 100644 glance/templates/bin/_post.sh.tpl create mode 100644 glance/templates/job-ks-endpoints.yaml.yaml create mode 100644 glance/templates/job-ks-service.yaml create mode 100644 glance/templates/job-ks-user.yaml delete mode 100644 glance/templates/job-post.yaml create mode 100644 glance/templates/secret-keystone-admin.env.yaml create mode 100644 glance/templates/secret-keystone-user.env.yaml diff --git a/glance/templates/bin/_post.sh.tpl b/glance/templates/bin/_post.sh.tpl deleted file mode 100644 index d46e9249..00000000 --- a/glance/templates/bin/_post.sh.tpl +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -ex -export HOME=/tmp - -ansible localhost -vvv -m kolla_keystone_service -a "service_name=glance \ -service_type=image \ -description='Openstack Image' \ -endpoint_region='{{ .Values.keystone.glance_region_name }}' \ -url='{{ include "endpoint_glance_api_internal" . }}' \ -interface=admin \ -region_name='{{ .Values.keystone.admin_region_name }}' \ -auth='{{ include "keystone_auth" . }}'" \ --e "{'openstack_glance_auth': {{ include "keystone_auth" . }}}" - -ansible localhost -vvv -m kolla_keystone_service -a "service_name=glance \ -service_type=image \ -description='Openstack Image' \ -endpoint_region='{{ .Values.keystone.glance_region_name }}' \ -url='{{ include "endpoint_glance_api_internal" . }}' \ -interface=internal \ -region_name='{{ .Values.keystone.admin_region_name }}' \ -auth='{{ include "keystone_auth" . }}'" \ --e "{ 'openstack_glance_auth': {{ include "keystone_auth" . }} }" - -ansible localhost -vvv -m kolla_keystone_service -a "service_name=glance \ -service_type=image \ -description='Openstack Image' \ -endpoint_region='{{ .Values.keystone.glance_region_name }}' \ -url='{{ include "endpoint_glance_api_internal" . }}' \ -interface=public \ -region_name='{{ .Values.keystone.admin_region_name }}' \ -auth='{{ include "keystone_auth" . }}'" \ --e "{ 'openstack_glance_auth': {{ include "keystone_auth" . }} }" - -ansible localhost -vvv -m kolla_keystone_user -a "project=service \ -user={{ .Values.keystone.glance_user }} \ -password={{ .Values.keystone.glance_password }} \ -role=admin \ -region_name={{ .Values.keystone.admin_region_name }} \ -auth='{{ include "keystone_auth" . }}'" \ --e "{ 'openstack_glance_auth': {{ include "keystone_auth" . }} }" - diff --git a/glance/templates/configmap-bin.yaml b/glance/templates/configmap-bin.yaml index fe1e9d98..646d31de 100644 --- a/glance/templates/configmap-bin.yaml +++ b/glance/templates/configmap-bin.yaml @@ -5,5 +5,9 @@ metadata: data: init.sh: |+ {{ tuple "bin/_init.sh.tpl" . | include "template" | indent 4 }} - post.sh: |+ -{{ tuple "bin/_post.sh.tpl" . | include "template" | indent 4 }} + ks-service.sh: |+ +{{- include "common_keystone_service" . | indent 4 }} + ks-endpoints.sh: |+ +{{- include "common_keystone_endpoints" . | indent 4 }} + ks-user.sh: |+ +{{- include "common_keystone_user" . | indent 4 }} diff --git a/glance/templates/etc/_glance-api.conf.tpl b/glance/templates/etc/_glance-api.conf.tpl index 84134e65..90d70121 100644 --- a/glance/templates/etc/_glance-api.conf.tpl +++ b/glance/templates/etc/_glance-api.conf.tpl @@ -8,27 +8,28 @@ workers = {{ .Values.misc.workers }} registry_host = glance-registry # Enable Copy-on-Write show_image_direct_url = True - + [database] connection = mysql+pymysql://{{ .Values.database.glance_user }}:{{ .Values.database.glance_password }}@{{ .Values.database.address }}/{{ .Values.database.glance_database_name }} max_retries = -1 - + [keystone_authtoken] -auth_uri = {{ .Values.keystone.auth_uri }} -auth_url = {{ .Values.keystone.auth_url }} +auth_version = v3 +auth_url = {{ tuple "keystone" "internal" "public" . | include "endpoint_addr_lookup" }} auth_type = password -project_domain_id = default -user_domain_id = default -project_name = service +region_name = {{ .Values.keystone.glance_region_name }} +project_domain_name = {{ .Values.keystone.glance_project_domain }} +project_name = {{ .Values.keystone.glance_project_name }} +user_domain_name = {{ .Values.keystone.glance_user_domain }} username = {{ .Values.keystone.glance_user }} password = {{ .Values.keystone.glance_password }} - + [paste_deploy] flavor = keystone - + [oslo_messaging_notifications] driver = noop - + [glance_store] filesystem_store_datadir = /var/lib/glance/images/ {{- if .Values.development.enabled }} diff --git a/glance/templates/etc/_glance-registry.conf.tpl b/glance/templates/etc/_glance-registry.conf.tpl index 9e4df8d9..a18e3e77 100644 --- a/glance/templates/etc/_glance-registry.conf.tpl +++ b/glance/templates/etc/_glance-registry.conf.tpl @@ -4,23 +4,24 @@ use_syslog = False use_stderr = True bind_port = {{ .Values.network.port.registry }} workers = {{ .Values.misc.workers }} - + [database] connection = mysql+pymysql://{{ .Values.database.glance_user }}:{{ .Values.database.glance_password }}@{{ .Values.database.address }}/{{ .Values.database.glance_database_name }} max_retries = -1 - + [keystone_authtoken] -auth_uri = {{ .Values.keystone.auth_uri }} -auth_url = {{ .Values.keystone.auth_url }} +auth_version = v3 +auth_url = {{ tuple "keystone" "internal" "public" . | include "endpoint_addr_lookup" }} auth_type = password -project_domain_id = default -user_domain_id = default -project_name = service +region_name = {{ .Values.keystone.glance_region_name }} +project_domain_name = {{ .Values.keystone.glance_project_domain }} +project_name = {{ .Values.keystone.glance_project_name }} +user_domain_name = {{ .Values.keystone.glance_user_domain }} username = {{ .Values.keystone.glance_user }} password = {{ .Values.keystone.glance_password }} - + [paste_deploy] flavor = keystone - + [oslo_messaging_notifications] driver = noop diff --git a/glance/templates/job-ks-endpoints.yaml.yaml b/glance/templates/job-ks-endpoints.yaml.yaml new file mode 100644 index 00000000..45910b2b --- /dev/null +++ b/glance/templates/job-ks-endpoints.yaml.yaml @@ -0,0 +1,50 @@ +{{- $envAll := . }} +{{- $ksAdminSecret := .Values.keystone_secrets.admin }} +{{- $dependencies := .Values.dependencies.ks_endpoints }} +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-ks-endpoints +spec: + template: + metadata: + annotations: + pod.beta.kubernetes.io/init-containers: '[ +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} + ]' + spec: + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: +{{- range $key1, $osServiceName := tuple "glance" }} +{{- range $key2, $osServiceEndPoint := tuple "admin" "internal" "public" }} + - name: {{ $osServiceName }}-ks-endpoints-{{ $osServiceEndPoint }} + image: {{ $envAll.Values.images.ks_endpoints }} + imagePullPolicy: {{ $envAll.Values.images.pull_policy }} + command: + - bash + - /tmp/ks-endpoints.sh + volumeMounts: + - name: ks-endpoints-sh + mountPath: /tmp/ks-endpoints.sh + subPath: ks-endpoints.sh + readOnly: true + env: +{{- with $env := dict "ksUserSecret" $ksAdminSecret }} +{{- include "env_ks_openrc_tpl" $env | indent 12 }} +{{- end }} + - name: OS_SVC_ENDPOINT + value: {{ $osServiceEndPoint }} + - name: OS_SERVICE_NAME + value: {{ $osServiceName }} + - name: OS_SERVICE_TYPE + value: {{ tuple $osServiceName $envAll | include "endpoint_type_lookup" }} + - name: OS_SERVICE_ENDPOINT + value: {{ tuple $osServiceName $osServiceEndPoint "api" $envAll | include "endpoint_addr_lookup" }} +{{- end }} +{{- end }} + volumes: + - name: ks-endpoints-sh + configMap: + name: glance-bin diff --git a/glance/templates/job-ks-service.yaml b/glance/templates/job-ks-service.yaml new file mode 100644 index 00000000..5ee441a7 --- /dev/null +++ b/glance/templates/job-ks-service.yaml @@ -0,0 +1,44 @@ +{{- $envAll := . }} +{{- $ksAdminSecret := .Values.keystone_secrets.admin }} +{{- $dependencies := .Values.dependencies.ks_service }} +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-ks-service +spec: + template: + metadata: + annotations: + pod.beta.kubernetes.io/init-containers: '[ +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} + ]' + spec: + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: +{{- range $key1, $osServiceName := tuple "glance" }} + - name: {{ $osServiceName }}-ks-service-registration + image: {{ $envAll.Values.images.ks_service }} + imagePullPolicy: {{ $envAll.Values.images.pull_policy }} + command: + - bash + - /tmp/ks-service.sh + volumeMounts: + - name: ks-service-sh + mountPath: /tmp/ks-service.sh + subPath: ks-service.sh + readOnly: true + env: +{{- with $env := dict "ksUserSecret" $ksAdminSecret }} +{{- include "env_ks_openrc_tpl" $env | indent 12 }} +{{- end }} + - name: OS_SERVICE_NAME + value: {{ $osServiceName }} + - name: OS_SERVICE_TYPE + value: {{ tuple $osServiceName $envAll | include "endpoint_type_lookup" }} +{{- end }} + volumes: + - name: ks-service-sh + configMap: + name: glance-bin diff --git a/glance/templates/job-ks-user.yaml b/glance/templates/job-ks-user.yaml new file mode 100644 index 00000000..4098c6ef --- /dev/null +++ b/glance/templates/job-ks-user.yaml @@ -0,0 +1,46 @@ +{{- $ksAdminSecret := .Values.keystone.admin_secret | default "glance-env-keystone-admin" }} +{{- $ksUserSecret := .Values.keystone.user_secret | default "glance-env-keystone-user" }} +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.ks_user }} +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-ks-user +spec: + template: + metadata: + annotations: + pod.beta.kubernetes.io/init-containers: '[ +{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} + ]' + spec: + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: + - name: glance-ks-user + image: {{ .Values.images.ks_user }} + imagePullPolicy: {{ .Values.images.pull_policy }} + command: + - bash + - /tmp/ks-user.sh + volumeMounts: + - name: ks-user-sh + mountPath: /tmp/ks-user.sh + subPath: ks-user.sh + readOnly: true + env: +{{- with $env := dict "ksUserSecret" $ksAdminSecret }} +{{- include "env_ks_openrc_tpl" $env | indent 12 }} +{{- end }} + - name: SERVICE_OS_SERVICE_NAME + value: "glance" +{{- with $env := dict "ksUserSecret" $ksUserSecret }} +{{- include "env_ks_user_create_openrc_tpl" $env | indent 12 }} +{{- end }} + - name: SERVICE_OS_ROLE + value: {{ .Values.keystone.glance_user_role | quote }} + volumes: + - name: ks-user-sh + configMap: + name: glance-bin diff --git a/glance/templates/job-post.yaml b/glance/templates/job-post.yaml deleted file mode 100644 index bbb53d76..00000000 --- a/glance/templates/job-post.yaml +++ /dev/null @@ -1,35 +0,0 @@ -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.post }} -apiVersion: batch/v1 -kind: Job -metadata: - name: glance-post -spec: - template: - metadata: - annotations: - pod.beta.kubernetes.io/init-containers: '[ -{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }} - ]' - spec: - nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} - restartPolicy: OnFailure - containers: - - name: glance-post - image: {{ .Values.images.post }} - imagePullPolicy: {{ .Values.images.pull_policy }} - command: - - bash - - /tmp/post.sh - volumeMounts: - - name: postsh - mountPath: /tmp/post.sh - subPath: post.sh - env: - - name: ANSIBLE_LIBRARY - value: /usr/share/ansible/ - volumes: - - name: postsh - configMap: - name: glance-bin diff --git a/glance/templates/secret-keystone-admin.env.yaml b/glance/templates/secret-keystone-admin.env.yaml new file mode 100644 index 00000000..4bd3eafc --- /dev/null +++ b/glance/templates/secret-keystone-admin.env.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.keystone_secrets.admin }} +type: Opaque +data: + OS_AUTH_URL: | +{{ tuple "keystone" "admin" "admin" . | include "endpoint_addr_lookup" | b64enc | indent 4 }} + OS_REGION_NAME: | +{{ .Values.keystone.admin_region_name | b64enc | indent 4 }} + OS_PROJECT_DOMAIN_NAME: | +{{ .Values.keystone.admin_project_domain | b64enc | indent 4 }} + OS_PROJECT_NAME: | +{{ .Values.keystone.admin_project_name | b64enc | indent 4 }} + OS_USER_DOMAIN_NAME: | +{{ .Values.keystone.admin_user_domain | b64enc | indent 4 }} + OS_USERNAME: | +{{ .Values.keystone.admin_user | b64enc | indent 4 }} + OS_PASSWORD: | +{{ .Values.keystone.admin_password | b64enc | indent 4 }} diff --git a/glance/templates/secret-keystone-user.env.yaml b/glance/templates/secret-keystone-user.env.yaml new file mode 100644 index 00000000..be15e614 --- /dev/null +++ b/glance/templates/secret-keystone-user.env.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.keystone_secrets.user }} +type: Opaque +data: + OS_AUTH_URL: | +{{ tuple "keystone" "internal" "public" . | include "endpoint_addr_lookup" | b64enc | indent 4 }} + OS_REGION_NAME: | +{{ .Values.keystone.glance_region_name | b64enc | indent 4 }} + OS_PROJECT_DOMAIN_NAME: | +{{ .Values.keystone.glance_project_domain | b64enc | indent 4 }} + OS_PROJECT_NAME: | +{{ .Values.keystone.glance_project_name | b64enc | indent 4 }} + OS_USER_DOMAIN_NAME: | +{{ .Values.keystone.glance_user_domain | b64enc | indent 4 }} + OS_USERNAME: | +{{ .Values.keystone.glance_user | b64enc | indent 4 }} + OS_PASSWORD: | +{{ .Values.keystone.glance_password | b64enc | indent 4 }} diff --git a/glance/values.yaml b/glance/values.yaml index d10670fe..25de8878 100644 --- a/glance/values.yaml +++ b/glance/values.yaml @@ -17,10 +17,12 @@ labels: images: db_sync: quay.io/stackanetes/stackanetes-glance-api:newton + ks_user: quay.io/stackanetes/stackanetes-glance-api:newton + ks_service: quay.io/stackanetes/stackanetes-glance-api:newton + ks_endpoints: quay.io/stackanetes/stackanetes-glance-api:newton api: quay.io/stackanetes/stackanetes-glance-api:newton init: quay.io/stackanetes/stackanetes-kolla-toolbox:newton registry: quay.io/stackanetes/stackanetes-glance-registry:newton - post: quay.io/stackanetes/stackanetes-kolla-toolbox:newton dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.1.0 pull_policy: "IfNotPresent" @@ -31,16 +33,24 @@ upgrades: max_unavailable: 1 max_surge: 3 +keystone_secrets: + admin: "glance-env-keystone-admin" + user: "glance-env-keystone-user" + keystone: - auth_uri: "http://keystone-api:5000" - auth_url: "http://keystone-api:35357" admin_user: "admin" + admin_user_domain: "default" admin_password: "password" admin_project_name: "admin" + admin_project_domain: "default" admin_region_name: "RegionOne" glance_user: "glance" + glance_user_domain: "default" + glance_user_role: "admin" glance_password: "password" + glance_project_name: "service" + glance_project_domain: "default" glance_region_name: "RegionOne" network: @@ -77,7 +87,8 @@ dependencies: jobs: - glance-init - glance-db-sync - - keystone-db-sync + - glance-ks-user + - glance-ks-endpoints service: - keystone-api - mariadb @@ -85,7 +96,8 @@ dependencies: jobs: - glance-init - glance-db-sync - - keystone-db-sync + - glance-ks-user + - glance-ks-endpoints service: - keystone-api - mariadb @@ -103,20 +115,19 @@ dependencies: - mariadb-seed service: - mariadb - post: + ks_user: + service: + - keystone-api + ks_service: + service: + - keystone-api + ks_endpoints: jobs: - - glance-init - - glance-db-sync - - keystone-db-sync - - keystone-init - - mariadb-seed + - glance-ks-service service: - - mariadb - keystone-api - - glance-api - - glance-registry -# typically overriden by environmental +# typically overriden by environmental # values, but should include all endpoints # required by this chart endpoints: @@ -138,4 +149,3 @@ endpoints: port: admin: 35357 public: 5000 -