-
Notifications
You must be signed in to change notification settings - Fork 75
/
cronjob.yaml
186 lines (186 loc) · 7.09 KB
/
cronjob.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
{{- if .Values.apiVersionOverrides.cronjob -}}
apiVersion: {{ .Values.apiVersionOverrides.cronjob }}
{{- else if .Capabilities.APIVersions.Has "batch/v1/CronJob" }}
apiVersion: batch/v1
{{- else if .Capabilities.APIVersions.Has "batch/v1beta1/CronJob" }}
apiVersion: batch/v1beta1
{{- else }}
{{- fail "\n\n ERROR: You must have at least batch/v1beta1 to use CronJob" }}
{{- end }}
kind: CronJob
metadata:
name: {{ include "renovate.fullname" . }}
labels:
{{- include "renovate.labels" . | nindent 4 }}
{{- with .Values.cronjob.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.cronjob.annotations }}
annotations:
{{ toYaml .Values.cronjob.annotations | nindent 4 }}
{{- end }}
spec:
schedule: "{{ .Values.cronjob.schedule }}"
{{- with .Values.cronjob.suspend }}
suspend: {{ . }}
{{- end }}
{{- with .Values.cronjob.concurrencyPolicy }}
concurrencyPolicy: {{ . }}
{{- end }}
{{- with .Values.cronjob.failedJobsHistoryLimit }}
failedJobsHistoryLimit: {{ . }}
{{- end }}
{{- with .Values.cronjob.successfulJobsHistoryLimit }}
successfulJobsHistoryLimit: {{ . }}
{{- end }}
jobTemplate:
metadata:
labels:
{{- include "renovate.selectorLabels" . | nindent 8 }}
spec:
backoffLimit: {{ .Values.cronjob.jobBackoffLimit }}
template:
metadata:
labels:
{{- include "renovate.selectorLabels" . | nindent 12 }}
{{- with .Values.pod.labels }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.pod.annotations }}
annotations:
{{ toYaml .Values.pod.annotations | nindent 12 }}
{{- end }}
spec:
serviceAccountName: {{ include "renovate.serviceAccountName" . }}
restartPolicy: {{ .Values.cronjob.jobRestartPolicy }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ include "renovate.imageTag" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.dind.enabled }}
command: ["/bin/bash", "-c"]
args:
- |
trap "touch /tmp/main-terminated" EXIT
while true; do if [[ -f "/tmp/dind-started" ]]; then break; fi; sleep 1; done
renovate
{{- end }}
{{- if or .Values.renovate.config .Values.ssh_config.enabled .Values.dind.enabled .Values.extraVolumes }}
volumeMounts:
{{- if .Values.renovate.config }}
- name: config-volume
mountPath: /usr/src/app/config.json
subPath: config.json
{{- end }}
{{- if .Values.ssh_config.enabled }}
- name: ssh-config-volume
mountPath: /home/ubuntu/.ssh
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 14 }}
{{- end }}
{{- end }}
{{- if .Values.dind.enabled }}
- name: {{ .Chart.Name }}-tmp-volume
mountPath: /tmp
{{- end }}
{{- if or .Values.redis.enabled .Values.renovate.existingConfigFile .Values.env .Values.dind.enabled }}
env:
{{- if .Values.renovate.existingConfigFile }}
- name: RENOVATE_CONFIG_FILE
value: {{ .Values.renovate.existingConfigFile }}
{{- else if .Values.renovate.config }}
- name: RENOVATE_CONFIG_FILE
value: /usr/src/app/config.json
{{- end }}
{{- if .Values.redis.enabled }}
- name: RENOVATE_REDIS_URL
value: redis://{{ include "renovate.redisHost" . }}
{{- end }}
{{- range $k, $v := .Values.env }}
- name: {{ $k | quote }}
value: {{ $v | quote }}
{{- end }}
{{- if .Values.dind.enabled }}
- name: DOCKER_HOST
value: 127.0.0.1:2376
- name: DOCKER_CERT_PATH
value: "/tmp/certs/client"
- name: DOCKER_TLS_VERIFY
value: "true"
{{- end }}
{{- end }}
{{- if or .Values.secrets .Values.existingSecret .Values.envFrom }}
envFrom:
{{- if or .Values.secrets .Values.existingSecret }}
- secretRef:
name: {{ template "renovate.secretName" . }}
{{- end }}
{{- with .Values.envFrom }}
{{- toYaml . | nindent 16 }}
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 16 }}
{{- if .Values.dind.enabled }}
- name: {{ .Chart.Name }}-dind
image: "{{ .Values.dind.image.repository }}:{{ .Values.dind.image.tag }}"
imagePullPolicy: {{ .Values.dind.image.pullPolicy }}
command: ["/bin/sh", "-c"]
args:
- |
dockerd-entrypoint.sh &
CHILD_PID=$!
while ! (pgrep containerd); do sleep 1; done
touch /tmp/dind-started
(while true; do if [[ -f "/tmp/main-terminated" ]]; then kill $CHILD_PID; fi; sleep 1; done) &
wait $CHILD_PID
if [[ -f "/tmp/main-terminated" ]]; then exit 0; fi
env:
- name: DOCKER_TLS_CERTDIR
value: "/tmp/certs"
securityContext:
privileged: true
volumeMounts:
- name: {{ .Chart.Name }}-tmp-volume
mountPath: /tmp
{{- end }}
volumes:
{{- if .Values.renovate.config }}
- name: config-volume
configMap:
name: {{ include "renovate.fullname" . }}-config
{{- end }}
{{- if .Values.ssh_config.enabled }}
- name: ssh-config-volume
secret:
secretName: {{ include "renovate.sshSecretName" .}}
{{- end }}
{{- if .Values.dind.enabled }}
- name: {{ .Chart.Name }}-tmp-volume
emptyDir: {}
{{- end }}
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}