Merge "[DMaaP DR Node] v1.16+ compatible templates"
[oom.git] / kubernetes / common / elasticsearch / components / curator / templates / cronjob.yaml
1 # Copyright © 2020 Bitnami, AT&T, Amdocs, Bell Canada, highstreet technologies
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 {{- if .Values.enabled }}
15 {{ $role := "curator" -}}
16 {{ $suffix := $role -}}
17 {{ $labels := (dict "role" $role) -}}
18 apiVersion: batch/v1beta1
19 kind: CronJob
20 metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }}
21   {{- if .Values.cronjob.annotations }}
22   annotations: {{- toYaml .Values.cronjob.annotations | indent 4 }}
23   {{- end }}
24 spec:
25   schedule: "{{ .Values.cronjob.schedule }}"
26   {{- with .Values.cronjob.concurrencyPolicy }}
27   concurrencyPolicy: {{ . }}
28   {{- end }}
29   {{- with .Values.cronjob.failedJobsHistoryLimit }}
30   failedJobsHistoryLimit: {{ . }}
31   {{- end }}
32   {{- with .Values.cronjob.successfulJobsHistoryLimit }}
33   successfulJobsHistoryLimit: {{ . }}
34   {{- end }}
35   jobTemplate:
36     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
37     spec:
38       template:
39         metadata: {{- include "common.templateMetadata" . | nindent 10 }}
40         spec:
41           volumes:
42             - name: config-volume
43               configMap:
44                 name: {{ template "common.fullname" . }}-curator
45             {{- if .Values.extraVolumes }}
46             {{- toYaml .Values.extraVolumes | nindent 12 }}
47             {{- end }}
48           restartPolicy: {{ .Values.global.restartPolicy | default .Values.cronjob.jobRestartPolicy }}
49           {{- if .Values.priorityClassName }}
50           priorityClassName: {{ .Values.priorityClassName | quote }}
51           {{- end }}
52 {{- include "elasticsearch.imagePullSecrets" . | indent 10 }}
53           {{- if .Values.extraInitContainers }}
54           initContainers:
55             {{- range $key, $value := .Values.extraInitContainers }}
56             - name: "{{ $key }}"
57             {{- toYaml $value | nindent 14 }}
58             {{- end }}
59           {{- end }}
60           {{- if .Values.rbac.enabled }}
61           serviceAccountName: {{ include "elasticsearch.curator.serviceAccountName" . }}
62           {{- end }}
63           {{- if .Values.affinity }}
64           affinity: {{- include "common.tplValue" (dict "value" .Values.affinity "context" $) | nindent 12 }}
65           {{- end }}
66           {{- if .Values.nodeSelector }}
67           nodeSelector: {{- include "common.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 12 }}
68           {{- end }}
69           {{- if .Values.tolerations }}
70           tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 12 }}
71           {{- end }}
72           {{- if .Values.securityContext }}
73           securityContext: {{- toYaml .Values.securityContext | nindent 12 }}
74           {{- end }}
75           containers:
76             - name: {{ template "common.fullname" . }}-curator
77               image: {{printf "%s/%s:%s" (include "common.repository" .)  .Values.image.imageName  .Values.image.tag }}
78               imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
79               volumeMounts:
80                 - name: config-volume
81                   mountPath: /etc/es-curator
82                 {{- if .Values.extraVolumeMounts }}
83                 {{- toYaml .Values.extraVolumeMounts | nindent 16 }}
84                 {{- end }}
85               {{ if .Values.command }}
86               command: {{ toYaml .Values.command | nindent 16 }}
87               {{- end }}
88               {{- if .Values.dryrun }}
89               args: [ "--dry-run", "--config", "/etc/es-curator/config.yml", "/etc/es-curator/action_file.yml" ]
90               {{- else }}
91               args: [ "--config", "/etc/es-curator/config.yml", "/etc/es-curator/action_file.yml" ]
92               {{- end }}
93               env:
94                 {{- if .Values.env }}
95                 {{- range $key,$value := .Values.env }}
96                 - name: {{ $key | upper | quote}}
97                   value: {{ $value | quote}}
98                 {{- end }}
99                 {{- end }}
100                 {{- if .Values.envFromSecrets }}
101                 {{- range $key,$value := .Values.envFromSecrets }}
102                 - name: {{ $key | upper | quote}}
103                   valueFrom:
104                     secretKeyRef:
105                       name: {{ $value.from.secret | quote}}
106                       key: {{ $value.from.key | quote}}
107                 {{- end }}
108                 {{- end }}
109               {{- if .Values.resources }}
110               resources: {{- toYaml .Values.resources | nindent 16 }}
111               {{- end }}
112 {{- end }}