Skip to content

Commit 9115e97

Browse files
committed
feat: add extra containers to cleanup cronjob
1 parent 555241b commit 9115e97

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

helm/charts/kratos/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,14 @@ Check if list contains object
238238
{{- end -}}
239239
{{- end -}}
240240
{{- end -}}
241+
242+
{{/*
243+
Create the name of the service account for the Cleanup CronJob to use
244+
*/}}
245+
{{- define "kratos.cleanup.serviceAccountName" -}}
246+
{{- if .Values.cronjob.cleanup.serviceAccount.create -}}
247+
{{- printf "%s-cleanup" (default (include "kratos.fullname" .) .Values.cronjob.cleanup.serviceAccount.name) -}}
248+
{{- else -}}
249+
{{- include "kratos.serviceAccountName" . -}}
250+
{{- end -}}
251+
{{- end -}}

helm/charts/kratos/templates/cronjob-cleanup.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ spec:
8787
- name: {{ include "kratos.name" . }}-config-volume
8888
mountPath: /etc/config
8989
readOnly: true
90+
{{- if .Values.cronjob.cleanup.extraContainers }}
91+
{{- toYaml .Values.cronjob.cleanup.extraContainers | nindent 12 }}
92+
{{- end }}
9093
{{- with .Values.cronjob.cleanup.nodeSelector }}
9194
nodeSelector:
9295
{{- toYaml . | nindent 12 }}
@@ -103,4 +106,7 @@ spec:
103106
affinity:
104107
{{- toYaml . | nindent 12 }}
105108
{{- end }}
109+
serviceAccountName: {{ include "kratos.cleanup.serviceAccountName" . }}
110+
automountServiceAccountToken: {{ .Values.cronjob.cleanup.automountServiceAccountToken }}
111+
shareProcessNamespace: {{ .Values.cronjob.cleanup.shareProcessNamespace }}
106112
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.cronjob.cleanup.serviceAccount.create -}}
2+
---
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: {{ include "kratos.cleanup.serviceAccountName" . }}
7+
{{- if .Release.Namespace }}
8+
namespace: {{ .Release.Namespace }}
9+
{{- end }}
10+
labels:
11+
{{- include "kratos.labels" . | nindent 4 }}
12+
{{- with .Values.cronjob.cleanup.serviceAccount.annotations }}
13+
annotations:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
automountServiceAccountToken: {{ .Values.cronjob.cleanup.automountServiceAccountToken }}
17+
{{- end -}}

helm/charts/kratos/values.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,32 @@ cronjob:
695695
# -- Set custom cron job level annotations
696696
annotations: {}
697697

698+
# -- If you want to add extra sidecar containers.
699+
extraContainers: []
700+
# extraContainers: |
701+
# - name: cloud-sql-proxy
702+
# image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.0
703+
# command: ["/cloud_sql_proxy"]
704+
# args: ["--port=5432", "--exit-zero-on-sigterm", "myproject:myregion:myinstance"]
705+
706+
# -- Set automounting of the SA token
707+
automountServiceAccountToken: false
708+
709+
# -- Set sharing process namespace
710+
shareProcessNamespace: false
711+
712+
# -- Specify the serviceAccountName value.
713+
# Sometime you need to provide specific permissions for the cleanup cronjob.
714+
# For example installing Kratos on a cluster with a PosSecurityPolicy and Istio.
715+
# Uncomment if you need to provide a ServiceAccount for the cleanup cronjob.
716+
serviceAccount:
717+
# -- Specifies whether a service account should be created
718+
create: true
719+
# -- Annotations to add to the service account
720+
annotations: {}
721+
# -- The name of the service account to use. If not set and create is true, a name is generated using the fullname template
722+
name: ""
723+
698724
# -- Specify pod metadata, this metadata is added directly to the pod, and not higher objects
699725
podMetadata:
700726
# -- Extra pod level labels

0 commit comments

Comments
 (0)