-
Notifications
You must be signed in to change notification settings - Fork 161
/
cronjob.yaml
194 lines (194 loc) · 10.4 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
187
188
189
190
191
192
193
194
{{- if .Values.housekeeping.enabled -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ printf "%s-housekeeping" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: housekeeping
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
concurrencyPolicy: {{ .Values.housekeeping.concurrencyPolicy }}
failedJobsHistoryLimit: {{ .Values.housekeeping.failedJobsHistoryLimit }}
schedule: {{ .Values.housekeeping.schedule | quote }}
successfulJobsHistoryLimit: {{ .Values.housekeeping.successfulJobsHistoryLimit }}
suspend: {{ .Values.housekeeping.suspend }}
jobTemplate:
metadata:
labels:
{{- include "common.labels.standard" . | nindent 8 }}
spec:
template:
metadata:
{{- if .Values.housekeeping.podAnnotations }}
annotations:
{{- include "common.tplvalues.render" ( dict "value" .Values.housekeeping.podAnnotations "context" $ ) | nindent 12 }}
{{- end }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.housekeeping.podLabels "context" $ ) | nindent 12 }}
app.kubernetes.io/component: housekeeping
spec:
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image) "context" $) | nindent 10 }}
serviceAccountName: {{ include "netbox.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.housekeeping.automountServiceAccountToken }}
{{- if .Values.housekeeping.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.housekeeping.podSecurityContext "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.housekeeping.initContainers }}
initContainers: {{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.initContainers "context" $) | trim | nindent 12 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-housekeeping
{{- if .Values.housekeeping.securityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.housekeeping.securityContext "context" $) | nindent 14 }}
{{- end }}
image: {{ include "netbox.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.housekeeping.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.command "context" $) | nindent 14 }}
{{- end }}
{{- if .Values.housekeeping.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.args "context" $) | nindent 14 }}
{{- end }}
{{- if .Values.housekeeping.extraEnvs }}
env: {{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.extraEnvs "context" $) | nindent 14 }}
{{- end }}
{{- if or .Values.housekeeping.extraEnvVarsCM .Values.housekeeping.extraEnvVarsSecret }}
envFrom:
{{- if .Values.housekeeping.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.housekeeping.extraEnvVarsCM "context" $) }}
{{- end }}
{{- if .Values.housekeeping.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.housekeeping.extraEnvVarsSecret "context" $) }}
{{- end }}
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/netbox/config/configuration.py
subPath: configuration.py
readOnly: true
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_config.py
subPath: ldap_config.py
readOnly: true
{{- if .Values.remoteAuth.ldap.caCertData }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_ca.crt
subPath: ldap_ca.crt
readOnly: true
{{- end }}
{{- end }}
- name: config
mountPath: /run/config/netbox
readOnly: true
- name: secrets
mountPath: /run/secrets/netbox
readOnly: true
{{- include "netbox.extraConfig.volumeMounts" . | nindent 12 }}
- name: netbox-tmp
mountPath: /tmp
- name: media
mountPath: /opt/netbox/netbox/media
subPath: {{ .Values.persistence.subPath | default "" | quote }}
readOnly: {{ .Values.housekeeping.readOnlyPersistence | default false }}
{{- if .Values.reportsPersistence.enabled }}
- name: reports
mountPath: /opt/netbox/netbox/reports
subPath: {{ .Values.reportsPersistence.subPath | default "" | quote }}
readOnly: {{ .Values.housekeeping.readOnlyPersistence | default false }}
{{- end }}
{{- if .Values.scriptsPersistence.enabled }}
- name: scripts
mountPath: /opt/netbox/netbox/scripts
subPath: {{ .Values.scriptsPersistence.subPath | default "" | quote }}
readOnly: {{ .Values.housekeeping.readOnlyPersistence | default false }}
{{- end }}
{{- if .Values.housekeeping.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.housekeeping.resources }}
resources: {{ toYaml .Values.housekeeping.resources | nindent 14 }}
{{- else if ne .Values.housekeeping.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.housekeeping.resourcesPreset) | nindent 14 }}
{{- end }}
{{- if .Values.housekeeping.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.sidecars "context" $) | nindent 10 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "common.names.fullname" . }}
- name: secrets
projected:
sources:
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.existingSecret "defaultNameSuffix" "config" "context" $) }}
items:
- key: secret_key
path: secret_key
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" (default .Values.email.existingSecretName .Values.existingSecret) "defaultNameSuffix" "config" "context" $) }}
items:
- key: {{ include "netbox.email.secretKey" . | quote }}
path: email_password
- secret:
name: {{ include "netbox.postgresql.secret" . | quote }}
items:
- key: {{ include "netbox.postgresql.secretKey" . | quote }}
path: db_password
- secret:
name: {{ include "netbox.tasksRedis.secret" . | quote }}
items:
- key: {{ include "netbox.tasksRedis.secretKey" . | quote }}
path: redis_tasks_password
- secret:
name: {{ include "netbox.cachingRedis.secret" . | quote }}
items:
- key: {{ include "netbox.cachingRedis.secretKey" . | quote }}
path: redis_cache_password
{{- include "netbox.extraConfig.volumes" . | nindent 10 }}
- name: netbox-tmp
emptyDir:
medium: Memory
- name: media
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-media" (include "common.names.fullname" .)) }}
readOnly: {{ .Values.housekeeping.readOnlyPersistence | default false }}
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.reportsPersistence.enabled }}
- name: reports
persistentVolumeClaim:
claimName: {{ .Values.reportsPersistence.existingClaim | default (printf "%s-reports" (include "common.names.fullname" .)) }}
readOnly: {{ .Values.housekeeping.readOnlyPersistence | default false }}
{{- end }}
{{- if .Values.scriptsPersistence.enabled }}
- name: scripts
persistentVolumeClaim:
claimName: {{ .Values.scriptsPersistence.existingClaim | default (printf "%s-scripts" (include "common.names.fullname" .)) }}
readOnly: {{ .Values.housekeeping.readOnlyPersistence | default false }}
{{- end }}
{{- if .Values.housekeeping.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.extraVolumes "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.housekeeping.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.housekeeping.nodeSelector "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.housekeeping.affinity }}
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.housekeeping.affinity "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.housekeeping.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.housekeeping.tolerations "context" .) | nindent 12 }}
{{- end }}
restartPolicy: {{ .Values.housekeeping.restartPolicy }}
{{- end -}}