[DCAEMOD] Uses new tpls for repos / images
[oom.git] / kubernetes / common / elasticsearch / components / curator / templates / cronjob.yaml
1 {{/*
2 # Copyright © 2020 Bitnami, AT&T, Amdocs, Bell Canada, highstreet technologies
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 {{- if .Values.enabled }}
17 {{ $role := "curator" -}}
18 {{ $suffix := $role -}}
19 {{ $labels := (dict "role" $role) -}}
20 apiVersion: batch/v1beta1
21 kind: CronJob
22 metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }}
23   {{- if .Values.cronjob.annotations }}
24   annotations: {{- toYaml .Values.cronjob.annotations | indent 4 }}
25   {{- end }}
26 spec:
27   schedule: "{{ .Values.cronjob.schedule }}"
28   {{- with .Values.cronjob.concurrencyPolicy }}
29   concurrencyPolicy: {{ . }}
30   {{- end }}
31   {{- with .Values.cronjob.failedJobsHistoryLimit }}
32   failedJobsHistoryLimit: {{ . }}
33   {{- end }}
34   {{- with .Values.cronjob.successfulJobsHistoryLimit }}
35   successfulJobsHistoryLimit: {{ . }}
36   {{- end }}
37   jobTemplate:
38     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
39     spec:
40       template:
41         metadata: {{- include "common.templateMetadata" . | nindent 10 }}
42         spec:
43           volumes:
44             - name: config-volume
45               configMap:
46                 name: {{ template "common.fullname" . }}-curator
47             {{- if .Values.extraVolumes }}
48             {{- toYaml .Values.extraVolumes | nindent 12 }}
49             {{- end }}
50           restartPolicy: {{ .Values.global.restartPolicy | default .Values.cronjob.jobRestartPolicy }}
51           {{- if .Values.priorityClassName }}
52           priorityClassName: {{ .Values.priorityClassName | quote }}
53           {{- end }}
54 {{- include "elasticsearch.imagePullSecrets" . | indent 10 }}
55           {{- if .Values.extraInitContainers }}
56           initContainers:
57             {{- range $key, $value := .Values.extraInitContainers }}
58             - name: "{{ $key }}"
59             {{- toYaml $value | nindent 14 }}
60             {{- end }}
61           {{- end }}
62           {{- if .Values.rbac.enabled }}
63           serviceAccountName: {{ include "elasticsearch.curator.serviceAccountName" . }}
64           {{- end }}
65           {{- if .Values.affinity }}
66           affinity: {{- include "common.tplValue" (dict "value" .Values.affinity "context" $) | nindent 12 }}
67           {{- end }}
68           {{- if .Values.nodeSelector }}
69           nodeSelector: {{- include "common.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 12 }}
70           {{- end }}
71           {{- if .Values.tolerations }}
72           tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 12 }}
73           {{- end }}
74           {{- if .Values.securityContext }}
75           securityContext: {{- toYaml .Values.securityContext | nindent 12 }}
76           {{- end }}
77           containers:
78             - name: {{ template "common.fullname" . }}-curator
79               image: {{printf "%s/%s" (include "common.repository" .)  .Values.image }}
80               imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
81               volumeMounts:
82                 - name: config-volume
83                   mountPath: /etc/es-curator
84                 {{- if .Values.extraVolumeMounts }}
85                 {{- toYaml .Values.extraVolumeMounts | nindent 16 }}
86                 {{- end }}
87               {{ if .Values.command }}
88               command: {{ toYaml .Values.command | nindent 16 }}
89               {{- end }}
90               {{- if .Values.dryrun }}
91               args: [ "--dry-run", "--config", "/etc/es-curator/config.yml", "/etc/es-curator/action_file.yml" ]
92               {{- else }}
93               args: [ "--config", "/etc/es-curator/config.yml", "/etc/es-curator/action_file.yml" ]
94               {{- end }}
95               env:
96                 {{- if .Values.env }}
97                 {{- range $key,$value := .Values.env }}
98                 - name: {{ $key | upper | quote}}
99                   value: {{ $value | quote}}
100                 {{- end }}
101                 {{- end }}
102                 {{- if .Values.envFromSecrets }}
103                 {{- range $key,$value := .Values.envFromSecrets }}
104                 - name: {{ $key | upper | quote}}
105                   valueFrom:
106                     secretKeyRef:
107                       name: {{ $value.from.secret | quote}}
108                       key: {{ $value.from.key | quote}}
109                 {{- end }}
110                 {{- end }}
111               {{- if .Values.resources }}
112               resources: {{- toYaml .Values.resources | nindent 16 }}
113               {{- end }}
114 {{- end }}