31ab047c7a5c4ac053a5e527b30a3778f252e865
[oom.git] / kubernetes / sdc / components / sdc-cs / templates / job.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, AT&T, Bell Canada
3 # Modifications Copyright © 2018  ZTE
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 */}}
17
18 apiVersion: batch/v1
19 kind: Job
20 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
21 spec:
22   backoffLimit: 20
23   template:
24     metadata:
25       labels:
26         app: {{ include "common.name" . }}-job
27         release: {{ include "common.release" . }}
28     spec:
29       restartPolicy: Never
30       initContainers:
31       - name: {{ include "common.name" . }}-init-readiness
32         image: {{ include "repositoryGenerator.image.readiness" . }}
33         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
34         command:
35         - /app/ready.py
36         args:
37         - --container-name
38         {{- if .Values.global.sdc_cassandra.localCluster }}
39         - sdc-cs
40         {{- else }}
41         - cassandra
42         {{- end }}
43         - "-t"
44         - "15"
45         env:
46         - name: NAMESPACE
47           valueFrom:
48             fieldRef:
49               apiVersion: v1
50               fieldPath: metadata.namespace
51         resources:
52           limits:
53             cpu: 100m
54             memory: 100Mi
55           requests:
56             cpu: 3m
57             memory: 20Mi
58       containers:
59       - name: {{ include "common.name" . }}-job
60         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.cassandraInitImage }}
61         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
62         volumeMounts:
63         - name: {{ include "common.fullname" . }}-environments
64           mountPath: /home/sdc/chef-solo/environments/
65         - name: {{ include "common.fullname" . }}-chef-cache
66           mountPath: /home/sdc/chef-solo/cache
67         env:
68         - name: ENVNAME
69           value: {{ .Values.env.name }}
70         - name: RELEASE
71           value: {{ .Values.config.release }}
72         - name: SDC_USER
73           valueFrom:
74             secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_user}
75         - name: SDC_PASSWORD
76           valueFrom:
77             secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_password}
78         - name: CS_PASSWORD
79           valueFrom:
80             secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: cs_password}
81         - name: HOST_IP
82           valueFrom:
83             fieldRef:
84               fieldPath: status.podIP
85         resources:
86           limits:
87             cpu: 800m
88             memory: 1024Mi
89           requests:
90             cpu: 200m
91             memory: 300Mi
92       {{ include "common.waitForJobContainer" . | indent 6 | trim }}
93       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
94       volumes:
95       - name: {{ include "common.fullname" . }}-environments
96         configMap:
97           name: {{ include "common.release" . }}-sdc-environments-configmap
98           defaultMode: 0755
99       - name: {{ include "common.fullname" . }}-chef-cache
100         emptyDir: {}
101       imagePullSecrets:
102       - name: "{{ include "common.namespace" . }}-docker-registry-key"
103       restartPolicy: Never