Skip to content

Commit

Permalink
feat: Add cronjob template (#25)
Browse files Browse the repository at this point in the history
* Add cronjob template

* Add cronjob to _app.yaml

* Update charts/helmet/templates/_cronjob.yaml

* Increase chart version

---------

Co-authored-by: Chiel Kooijman <chiel.kooijman@company.info>
Co-authored-by: Mohammad Abdolirad <m.abdolirad@gmail.com>
  • Loading branch information
3 people authored Jan 22, 2025
1 parent f9e559a commit dc4e838
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/helmet/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: helmet
description: Helmet is a library Helm Chart for grouping common logics. This chart is not deployable by itself.
home: https://github.com/companyinfo/helm-charts/blob/main/charts/helmet
type: library
version: "0.12.1"
appVersion: "0.12.1"
version: "0.13.0"
appVersion: "0.13.0"
keywords:
- common
- helper
Expand Down
1 change: 1 addition & 0 deletions charts/helmet/templates/_app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@

{{ include "helmet.serviceaccount" . }}
{{ include "helmet.servicemonitor" . }}
{{ include "helmet.cronjob" . }}
{{ include "helmet.podmonitor" . }}
{{- end }}
47 changes: 47 additions & 0 deletions charts/helmet/templates/_cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- define "helmet.cronjob" -}}
{{- if .Values.cronjob.enabled -}}
---
apiVersion: {{ include "common.capabilities.cronjob.apiVersion" . }}
kind: CronJob
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
concurrencyPolicy: {{ .Values.cronjob.concurrencyPolicy | quote }}
schedule: {{ .Values.cronjob.schedule | quote }}
successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }}
jobTemplate:
spec:
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 12 }}
{{- if .Values.cronjob.podAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.cronjob.podAnnotations "context" $) | nindent 12 }}
{{- end }}
spec:
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) | indent 10 }}
{{- if and .Values.cronjob.nodeSelector .Values.nodeSelector }}
nodeSelector: {{- default (toYaml .Values.nodeSelector) (toYaml .Values.cronjob.nodeSelector) | nindent 12 }}
{{- end }}
{{- if and .Values.cronjob.tolerations .Values.tolerations }}
tolerations: {{- default (toYaml .Values.tolerations) (toYaml .Values.cronjob.tolerations) | nindent 12 }}
{{- end }}
restartPolicy: OnFailure
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.cronjob.initContainers }}
initContainers: {{- include "common.tplvalues.render" (dict "value" .Values.cronjob.initContainers "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.cronjob.containers }}
containers: {{- include "common.tplvalues.render" (dict "value" .Values.cronjob.containers "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.cronjob.volumes }}
volumes: {{- include "common.tplvalues.render" (dict "value" .Values.cronjob.volumes "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
81 changes: 81 additions & 0 deletions charts/helmet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -853,3 +853,84 @@ exports:
## @param serviceAccount.labels Additional custom labels for the ServiceAccount
##
labels: {}

## Cronjob: create jobs on a repeated schedule
## Ref: https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
##
cronjob:
## @param cronjob.enabled
##
enabled: false

## @param cronjob.concurrencyPolicy Allow/Forbid/Replace concurrency
##
concurrencyPolicy: Allow

## @param cronjob.schedule run schedule for the cronjob
## Cron format: "<minute> <hour> <day_of_month> <month> <day_of_week>"
##
schedule: ""

## @param cronjob.successfulJobsHistoryLimit
##
successfulJobsHistoryLimit: 3

## @param nodeSelector Node labels for pod assignment.
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}

## @param tolerations Tolerations for pod assignment.
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []

## @param restartPolicy Restart conditions
## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
##
restartPolicy: OnFailure

## Configure APP pods Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
## @param podSecurityContext.enabled Enabled APP pods' Security Context
## @param podSecurityContext.fsGroup Set APP pod's Security Context fsGroup
##
podSecurityContext:
enabled: false
fsGroup: 0

## @param initContainers Add additional init containers to the APP pods
## Example:
## initContainers:
## - name: your-image-name
## image: your-image
## imagePullPolicy: Always
## ports:
## - name: portname
## containerPort: 1234
##
initContainers: []

## @param containers Add additional containers to the APP pods
## Example:
## containers:
## - name: your-image-name
## image: your-image
## imagePullPolicy: Always
## ports:
## - name: portname
## containerPort: 1234
##
containers: []

## @param volumes Array to add volumes (evaluated as a template)
## Example:
## volumes:
## - name: vol-conf
## configMap:
## name: "configmap-name"
## - name: vol-secret
## secret:
## secretName: "secret-name"
##
volumes: []

0 comments on commit dc4e838

Please sign in to comment.