job init container uses template, removed special image
This commit is contained in:
parent
705650c7d3
commit
1feb1dcccd
@ -8,12 +8,16 @@
|
||||
"env": [
|
||||
{
|
||||
"name": "POD_NAME",
|
||||
{{- if $deps.pod -}}
|
||||
"value": "{{- $deps.pod . 1 -}}"
|
||||
{{- else -}}
|
||||
"valueFrom": {
|
||||
"fieldRef": {
|
||||
"APIVersion": "v1",
|
||||
"fieldPath": "metadata.name"
|
||||
}
|
||||
}
|
||||
{{- end -}}
|
||||
},
|
||||
{
|
||||
"name": "NAMESPACE",
|
||||
@ -40,6 +44,10 @@
|
||||
"name": "DEPENDENCY_DAEMONSET",
|
||||
"value": "{{ include "joinListWithColon" $deps.daemonset }}"
|
||||
},
|
||||
{
|
||||
"name": "DEPENDENCY_CONTAINER",
|
||||
"value": "{{ include "joinListWithColon" $deps.container }}"
|
||||
},
|
||||
{
|
||||
"name": "COMMAND",
|
||||
"value": "echo done"
|
||||
|
@ -4,24 +4,27 @@ 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
|
||||
|
||||
TIMEOUT={{ .Values.jobs.import_boot_resources.timeout }}
|
||||
while [[ ${TIMEOUT} -gt 0 ]]; do
|
||||
if maas {{ .Values.credentials.admin_username }} boot-resources read | grep -q '\[\]';
|
||||
then
|
||||
echo 'Did not find boot resources. Will try again'
|
||||
let TIMEOUT-={{ .Values.jobs.import_boot_resources.retry_timer }}
|
||||
sleep {{ .Values.jobs.import_boot_resources.retry_timer }}
|
||||
else
|
||||
echo 'Boot resources found'
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
}
|
||||
|
||||
maas-region local_config_set \
|
||||
--database-host "{{ .Values.db_service_name }}.{{ .Release.Namespace}}" \
|
||||
--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"
|
||||
--maas-url "http://{{ .Values.ui_service_name }}.{{ .Release.Namespace }}:{{ .Values.network.port.service_gui }}/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
|
||||
@ -29,5 +32,5 @@ maas login {{ .Values.credentials.admin_username }} http://{{ .Values.ui_service
|
||||
# make call to import images
|
||||
maas {{ .Values.credentials.admin_username }} boot-resources import
|
||||
# see if we can find > 0 images
|
||||
sleep 10
|
||||
sleep {{ .Values.jobs.import_boot_resources.retry_timer }}
|
||||
check_for_download
|
@ -1,3 +1,5 @@
|
||||
{{- $envAll := . }}
|
||||
{{- $dependencies := .Values.dependencies.import_resources }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
@ -7,39 +9,13 @@ spec:
|
||||
metadata:
|
||||
annotations:
|
||||
pod.beta.kubernetes.io/init-containers: '[
|
||||
{
|
||||
"name": "init",
|
||||
"image": "{{ .Values.images.entrypoint }}",
|
||||
"imagePullPolicy": "{{ .Values.images.pull_policy }}",
|
||||
"env": [
|
||||
{
|
||||
"name": "NAMESPACE",
|
||||
"value": "{{ .Release.Namespace }}"
|
||||
},
|
||||
{
|
||||
"name": "POD_NAME",
|
||||
"value": "{{ .Values.dependencies.import_resources.pod }}"
|
||||
},
|
||||
{
|
||||
"name": "DEPENDENCY_SERVICE",
|
||||
"value": "{{ include "joinListWithColon" .Values.dependencies.import_resources.service }}"
|
||||
},
|
||||
{
|
||||
"name": "DEPENDENCY_CONTAINER",
|
||||
"value": "{{ .Values.dependencies.import_resources.container }}"
|
||||
},
|
||||
{
|
||||
"name": "COMMAND",
|
||||
"value": "echo done"
|
||||
}
|
||||
]
|
||||
}
|
||||
{{ tuple $envAll $dependencies | include "dep_check_init_cont" | indent 10 }}
|
||||
]'
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: region-import-resources
|
||||
image: {{ .Values.images.maas_toolbox }}
|
||||
image: {{ .Values.images.maas_region }}
|
||||
imagePullPolicy: {{ .Values.images.pull_policy }}
|
||||
command:
|
||||
- bash
|
||||
|
@ -14,19 +14,26 @@ database:
|
||||
|
||||
dependencies:
|
||||
import_resources:
|
||||
pod: maas-region-0
|
||||
container: maas-region
|
||||
pod:
|
||||
- maas-region-0
|
||||
container:
|
||||
- maas-region
|
||||
service:
|
||||
- maas-region-ui
|
||||
- db-service
|
||||
|
||||
images:
|
||||
maas_region: quay.io/attcomdev/maas-region:2.1.2-2
|
||||
maas_toolbox: quay.io/attcomdev/maas-toolbox:2.1.2
|
||||
maas_rack: quay.io/attcomdev/maas-rack:2.1.2-2
|
||||
entrypoint: quay.io/stackanetes/kubernetes-entrypoint:v0.1.0
|
||||
dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.1.0
|
||||
pull_policy: Always
|
||||
|
||||
jobs:
|
||||
import_boot_resources:
|
||||
retry_timer: 10
|
||||
#default timeout: 15 minutes
|
||||
timeout: 900
|
||||
|
||||
labels:
|
||||
node_selector_key: openstack-control-plane
|
||||
node_selector_value: enabled
|
||||
|
Loading…
Reference in New Issue
Block a user