blob: b5b97233a024c9793b864dab9fc0f178701264e9 [file] [log] [blame]
Nelson,Thomas(tn1381)(arthurdent3)4807fdf2018-09-19 16:52:36 -04001{{- if .Values.jobs.chroots.enabled }}
2{{- $root := . }}
3{{- $job := .Values.jobs.chroots }}
4apiVersion: batch/v1
5kind: Job
6metadata:
7 name: {{ template "common.fullname" . }}-chroots
8 annotations:
9 "helm.sh/hook": post-install,post-upgrade
10 "helm.sh/hook-weight": "-5"
11 "helm.sh/hook-delete-policy": hook-succeeded
12 labels:
13 app: {{ template "common.name" . }}
14 chart: {{ .Chart.Name }}
15 release: {{ .Release.Name }}
16 heritage: {{ .Release.Service }}
17 component: jobs
18 job: chroots
19spec:
20 activeDeadlineSeconds: {{ $job.activeDeadlineSeconds }}
21 backoffLimit: {{ $job.backoffLimit }}
22 completions: {{ $job.completions }}
23 parallelism: {{ $job.parallelism }}
24 template:
25 metadata:
26 labels:
27 app: {{ template "common.name" . }}
28 release: {{ .Release.Name }}
29 component: jobs
30 job: chroots
31 spec:
32 restartPolicy: {{ $job.restartPolicy }}
33 containers:
34 - name: main
35 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
dkamdocs6ad3a1c2018-12-21 09:25:53 +000036 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.image.pullPolicy }}
Nelson,Thomas(tn1381)(arthurdent3)4807fdf2018-09-19 16:52:36 -040037 command:
38 - /bin/bash
39 - -o
40 - pipefail
41 - -euc
42 {{- $port := .Values.service.ports.client.port }}
43 - >
44 sleep 15;
45 export SERVER={{ template "common.fullname" $root }}:{{ $port }};
46 {{- range $job.config.create }}
47 echo '==> {{ . }}';
48 echo '====> Create chroot if does not exist.';
49 zkCli.sh -server {{ template "common.fullname" $root }}:{{ $port }} get {{ . }} 2>&1 >/dev/null | grep 'cZxid'
50 || zkCli.sh -server {{ template "common.fullname" $root }}:{{ $port }} create {{ . }} "";
51 echo '====> Confirm chroot exists.';
52 zkCli.sh -server {{ template "common.fullname" $root }}:{{ $port }} get {{ . }} 2>&1 >/dev/null | grep 'cZxid';
53 echo '====> Chroot exists.';
54 {{- end }}
55 env:
56 {{- range $key, $value := $job.env }}
57 - name: {{ $key | upper | replace "." "_" }}
58 value: {{ $value | quote }}
59 {{- end }}
60 resources:
61{{ toYaml $job.resources | indent 12 }}
62{{- end -}}