|
| 1 | +--- |
| 2 | +apiVersion: batch/v1 |
| 3 | +kind: Job |
| 4 | +metadata: |
| 5 | + name: {{ .Release.Name }}-job-st2-apikey-load |
| 6 | + labels: |
| 7 | + app: st2 |
| 8 | + tier: backend |
| 9 | + vendor: stackstorm |
| 10 | + support: {{ template "supportMethod" . }} |
| 11 | + chart: {{ .Chart.Name }}-{{ .Chart.Version }} |
| 12 | + release: {{ .Release.Name }} |
| 13 | + heritage: {{ .Release.Service }} |
| 14 | + annotations: |
| 15 | + helm.sh/hook: post-install, post-upgrade, post-rollback |
| 16 | + helm.sh/hook-delete-policy: before-hook-creation |
| 17 | + helm.sh/hook-weight: "5" |
| 18 | +spec: |
| 19 | + template: |
| 20 | + metadata: |
| 21 | + name: job-st2-apikey-load |
| 22 | + labels: |
| 23 | + app: st2 |
| 24 | + tier: backend |
| 25 | + vendor: stackstorm |
| 26 | + support: {{ template "supportMethod" . }} |
| 27 | + chart: {{ .Chart.Name }}-{{ .Chart.Version }} |
| 28 | + release: {{ .Release.Name }} |
| 29 | + heritage: {{ .Release.Service }} |
| 30 | + annotations: |
| 31 | + # TODO: Investigate/propose running Helm hook only on condition when ConfigMap or Secret has changed |
| 32 | + checksum/urls: {{ include (print $.Template.BasePath "/configmaps_st2-urls.yaml") . | sha256sum }} |
| 33 | + checksum/apikeys: {{ include (print $.Template.BasePath "/secrets_st2apikeys.yaml") . | sha256sum }} |
| 34 | + spec: |
| 35 | + {{- if .Values.enterprise.enabled }} |
| 36 | + imagePullSecrets: |
| 37 | + - name: {{ .Release.Name }}-st2-license |
| 38 | + {{- end }} |
| 39 | + initContainers: |
| 40 | + # Sidecar container for generating st2client config with st2 username & password pair and sharing produced file with the main container |
| 41 | + - name: generate-st2client-config |
| 42 | + image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}" |
| 43 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 44 | + envFrom: |
| 45 | + - configMapRef: |
| 46 | + name: {{ .Release.Name }}-st2-urls |
| 47 | + env: |
| 48 | + - name: ST2_AUTH_USERNAME |
| 49 | + valueFrom: |
| 50 | + secretKeyRef: |
| 51 | + name: {{ .Release.Name }}-st2-auth |
| 52 | + key: username |
| 53 | + - name: ST2_AUTH_PASSWORD |
| 54 | + valueFrom: |
| 55 | + secretKeyRef: |
| 56 | + name: {{ .Release.Name }}-st2-auth |
| 57 | + key: password |
| 58 | + volumeMounts: |
| 59 | + - name: st2client-config-vol |
| 60 | + mountPath: /root/.st2/ |
| 61 | + # `st2 login` doesn't exit on failure correctly, use old methods instead. See bug: https://github.com/StackStorm/st2/issues/4338 |
| 62 | + command: |
| 63 | + - 'sh' |
| 64 | + - '-ec' |
| 65 | + - | |
| 66 | + cat <<EOT > /root/.st2/config |
| 67 | + [credentials] |
| 68 | + username = ${ST2_AUTH_USERNAME} |
| 69 | + password = ${ST2_AUTH_PASSWORD} |
| 70 | + EOT |
| 71 | + containers: |
| 72 | + - name: st2-apikey-load |
| 73 | + image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}" |
| 74 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 75 | + command: |
| 76 | + - st2 |
| 77 | + - apikey |
| 78 | + - load |
| 79 | + - /etc/st2/apikeys.yaml |
| 80 | + envFrom: |
| 81 | + - configMapRef: |
| 82 | + name: {{ .Release.Name }}-st2-urls |
| 83 | + volumeMounts: |
| 84 | + - name: st2client-config-vol |
| 85 | + mountPath: /root/.st2/ |
| 86 | + - name: st2-apikeys-vol |
| 87 | + mountPath: /etc/st2/apikeys.yaml |
| 88 | + subPath: apikeys.yaml |
| 89 | + # TODO: Find out default resource limits for this specific service (#5) |
| 90 | + #resources: |
| 91 | + volumes: |
| 92 | + - name: st2client-config-vol |
| 93 | + emptyDir: |
| 94 | + medium: Memory |
| 95 | + - name: st2-apikeys-vol |
| 96 | + secret: |
| 97 | + secretName: {{ .Release.Name }}-st2-apikeys |
| 98 | + restartPolicy: OnFailure |
| 99 | + |
1 | 100 | ---
|
2 | 101 | apiVersion: batch/v1
|
3 | 102 | kind: Job
|
|
0 commit comments