From ec00228bcd48f5dcb518db3df1de12f4af5cfd6c Mon Sep 17 00:00:00 2001 From: Larry Rensing Date: Tue, 24 Jan 2017 23:49:08 +0000 Subject: [PATCH] replaced existing systemd script with kubernetes job, also added configurable credentials for maas --- .../bin/_import-boot-resources.sh.tpl | 33 +++++++++ maas/templates/bin/_job-readiness.sh.tpl | 6 ++ .../bin/_maas-region-controller.postinst.tpl | 8 ++- maas/templates/bin/_start.sh.tpl | 8 +++ maas/templates/configmap-bin.yaml | 4 ++ maas/templates/configmap-etc.yaml | 2 + maas/templates/db-service.yaml | 13 ++++ maas/templates/deploy-region.yaml | 19 +++-- maas/templates/etc/_postgresql-config.tpl | 44 ++++++++++++ maas/templates/job-import.yaml | 72 +++++++++++++++++++ .../{service.yaml => maas-service.yaml} | 2 +- maas/values.yaml | 30 +++++++- 12 files changed, 230 insertions(+), 11 deletions(-) create mode 100644 maas/templates/bin/_import-boot-resources.sh.tpl create mode 100644 maas/templates/bin/_job-readiness.sh.tpl create mode 100644 maas/templates/db-service.yaml create mode 100644 maas/templates/etc/_postgresql-config.tpl create mode 100644 maas/templates/job-import.yaml rename maas/templates/{service.yaml => maas-service.yaml} (91%) diff --git a/maas/templates/bin/_import-boot-resources.sh.tpl b/maas/templates/bin/_import-boot-resources.sh.tpl new file mode 100644 index 0000000000..95c6b657b7 --- /dev/null +++ b/maas/templates/bin/_import-boot-resources.sh.tpl @@ -0,0 +1,33 @@ +#!/bin/sh + +set -ex + +function check_for_download { + + if maas {{ .Values.credentials.admin_username }} boot-resources read | grep -q '\[\]'; + then + echo 'Did not find boot resources. Will try again' + sleep 60 + exit 1 + else + echo 'Boot resources found' + exit 0 + fi + +} + +maas-region local_config_set \ + --database-host "{{ .Values.db_service_name }}.{{ .Release.Namespace}}" \ + --database-name "{{ .Values.database.db_name }}" \ + --database-user "{{ .Values.database.db_user }}" \ + --database-pass "{{ .Values.database.db_password }}" \ + --maas-url "http://{{ .Values.ui_service_name }}.{{ .Release.Namespace }}:80/MAAS" + +KEY=$(maas-region apikey --username={{ .Values.credentials.admin_username }}) +maas login {{ .Values.credentials.admin_username }} http://{{ .Values.ui_service_name }}.{{ .Release.Namespace }}/MAAS/ $KEY + +# make call to import images +maas {{ .Values.credentials.admin_username }} boot-resources import +# see if we can find > 0 images +sleep 10 +check_for_download diff --git a/maas/templates/bin/_job-readiness.sh.tpl b/maas/templates/bin/_job-readiness.sh.tpl new file mode 100644 index 0000000000..9eb9659fe4 --- /dev/null +++ b/maas/templates/bin/_job-readiness.sh.tpl @@ -0,0 +1,6 @@ +#!/bin/bash + +