krishnaa96 | 544863d | 2021-05-11 18:29:49 +0530 | [diff] [blame] | 1 | {{/* |
| 2 | # Copyright (C) 2021 Wipro Limited. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | */}} |
| 16 | apiVersion: batch/v1 |
| 17 | kind: Job |
| 18 | metadata: |
| 19 | name: {{ include "common.fullname" . }}-job |
| 20 | namespace: {{ include "common.namespace" . }} |
| 21 | labels: |
| 22 | app: {{ include "common.name" . }} |
| 23 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
| 24 | release: {{ include "common.release" . }} |
| 25 | heritage: {{ .Release.Service }} |
| 26 | spec: |
| 27 | backoffLimit: {{ .Values.backoffLimit }} |
| 28 | template: |
| 29 | metadata: |
| 30 | labels: |
| 31 | app: {{ include "common.name" . }} |
| 32 | release: {{ include "common.release" . }} |
| 33 | name: {{ include "common.name" . }} |
| 34 | spec: |
| 35 | initContainers: |
| 36 | - name: {{ include "common.name" . }}-readiness |
| 37 | command: |
| 38 | - /app/ready.py |
| 39 | args: |
| 40 | - --container-name |
| 41 | - {{ .Values.etcd.containerName }} |
| 42 | env: |
| 43 | - name: NAMESPACE |
| 44 | valueFrom: |
| 45 | fieldRef: |
| 46 | apiVersion: v1 |
| 47 | fieldPath: metadata.namespace |
| 48 | image: {{ include "repositoryGenerator.image.readiness" . }} |
| 49 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
Andreas Geissler | 4753743 | 2024-02-27 08:55:23 +0100 | [diff] [blame] | 50 | resources: |
| 51 | limits: |
| 52 | cpu: "100m" |
Andreas Geissler | 8cbb3d9 | 2024-03-12 16:44:56 +0100 | [diff] [blame] | 53 | memory: "500Mi" |
Andreas Geissler | 4753743 | 2024-02-27 08:55:23 +0100 | [diff] [blame] | 54 | requests: |
| 55 | cpu: "3m" |
Andreas Geissler | 8cbb3d9 | 2024-03-12 16:44:56 +0100 | [diff] [blame] | 56 | memory: "20Mi" |
krishnaa96 | 544863d | 2021-05-11 18:29:49 +0530 | [diff] [blame] | 57 | containers: |
| 58 | - name: {{ include "common.name" . }} |
| 59 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
| 60 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 61 | command: |
| 62 | - /bin/sh |
| 63 | - -ec |
| 64 | - | |
Andreas Geissler | 0239815 | 2022-05-10 10:30:11 +0200 | [diff] [blame] | 65 | {{- if include "common.onServiceMesh" . }} |
| 66 | echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }} |
krishnaa96 | 544863d | 2021-05-11 18:29:49 +0530 | [diff] [blame] | 67 | # Create users |
| 68 | export ETCDCTL_ENDPOINTS=http://${ETCD_HOST}:${ETCD_PORT} |
| 69 | export ETCDCTL_API=3 |
| 70 | echo "${ROOT_PASSWORD}" | etcdctl user add root --interactive=false |
| 71 | echo "${APP_PASSWORD}" | etcdctl user add ${APP_USER} --interactive=false |
| 72 | |
| 73 | # Create roles |
| 74 | etcdctl role add ${APP_ROLE} |
| 75 | etcdctl role grant-permission ${APP_ROLE} --prefix=true readwrite ${KEY_PREFIX} |
| 76 | |
| 77 | etcdctl user grant-role ${APP_USER} ${APP_ROLE} |
| 78 | etcdctl auth enable |
| 79 | env: |
| 80 | - name: ALLOW_NONE_AUTHENTICATION |
| 81 | value: "yes" |
| 82 | - name: ETCD_HOST |
| 83 | value: "{{ .Values.etcd.serviceName }}.{{ include "common.namespace" . }}" |
| 84 | - name: ETCD_PORT |
| 85 | value: "{{ .Values.etcd.port }}" |
| 86 | - name: ROOT_PASSWORD |
| 87 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-password" "key" "password" ) | indent 10 }} |
| 88 | - name: APP_USER |
| 89 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-creds" "key" "login") | indent 10 }} |
| 90 | - name: APP_PASSWORD |
| 91 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-creds" "key" "password") | indent 10 }} |
| 92 | - name: APP_ROLE |
| 93 | value: "{{ .Values.config.appRole }}" |
| 94 | - name: KEY_PREFIX |
| 95 | value: "{{ .Values.config.keyPrefix }}" |
| 96 | volumeMounts: |
| 97 | - mountPath: /etc/localtime |
| 98 | name: localtime |
| 99 | readOnly: true |
miroslavmasaryk | a7ac7f0 | 2023-03-01 14:12:26 +0100 | [diff] [blame] | 100 | resources: {{ include "common.resources" . | nindent 10 }} |
Andreas Geissler | 0239815 | 2022-05-10 10:30:11 +0200 | [diff] [blame] | 101 | {{ include "common.waitForJobContainer" . | indent 6 | trim }} |
krishnaa96 | 544863d | 2021-05-11 18:29:49 +0530 | [diff] [blame] | 102 | {{- if .Values.nodeSelector }} |
| 103 | nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }} |
| 104 | {{- end -}} |
| 105 | {{- if .Values.affinity }} |
| 106 | affinity: {{ toYaml .Values.affinity | nindent 10 }} |
| 107 | {{- end }} |
vladimir turok | d804418 | 2023-07-27 16:28:36 +0200 | [diff] [blame] | 108 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}} |
krishnaa96 | 544863d | 2021-05-11 18:29:49 +0530 | [diff] [blame] | 109 | volumes: |
| 110 | - name: localtime |
| 111 | hostPath: |
| 112 | path: /etc/localtime |
| 113 | restartPolicy: Never |
Andreas Geissler | bd0d31a | 2024-03-20 09:51:32 +0100 | [diff] [blame] | 114 | {{- include "common.imagePullSecrets" . | nindent 6 }} |