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