Skip to content

Commit

Permalink
support cronjobss in rails-application chart
Browse files Browse the repository at this point in the history
  • Loading branch information
klausmeyer committed Apr 25, 2024
1 parent 02bccec commit 7101ed9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/rails-application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
name: rails-application
description: Base chart for my rails applications
type: application
version: "0.1.0-alpha1"
version: "0.1.0-alpha2"
52 changes: 52 additions & 0 deletions charts/rails-application/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- range $cronjobName, $cronjobValues := .Values.cronjobs }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ printf "%s-%s-%s" (include "rails-application.fullname" $) "crons" $cronjobName }}
labels:
{{- include "rails-application.labels" $ | nindent 4 }}
spec:
schedule: {{ $cronjobValues.schedule | quote }}
jobTemplate:
spec:
template:
spec:
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml $ | nindent 12 }}
{{- end }}
serviceAccountName: {{ include "rails-application.serviceAccountName" $ }}
securityContext:
{{- toYaml $.Values.podSecurityContext | nindent 12 }}
containers:
- name: {{ printf "%s-%s-%s" (include "rails-application.fullname" $) "crons" $cronjobName }}
securityContext:
{{- toYaml $.Values.securityContext | nindent 16 }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Values.version }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
args:
{{- toYaml $cronjobValues.args | nindent 16 }}
envFrom:
- configMapRef:
name: {{ include "rails-application.fullname" $ }}
- secretRef:
name: {{ include "rails-application.fullname" $ }}
{{- with $.Values.volumes }}
volumes:
{{- toYaml $ | nindent 8 }}
{{- end }}
{{- with $.Values.nodeSelector }}
nodeSelector:
{{- toYaml $ | nindent 8 }}
{{- end }}
{{- with $.Values.affinity }}
affinity:
{{- toYaml $ | nindent 8 }}
{{- end }}
{{- with $.Values.tolerations }}
tolerations:
{{- toYaml $ | nindent 8 }}
{{- end }}
restartPolicy: OnFailure
---
{{- end }}
8 changes: 8 additions & 0 deletions charts/rails-application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

name: placeholder
version: "9.9.9"

image:
repository: my-application
pullPolicy: IfNotPresent
Expand Down Expand Up @@ -34,6 +37,11 @@ deployments:
path: /health/all
port: http

cronjobs: {}
# daily:
# schedule: "30 6 * * *"
# args: ["rake", "crons:daily"]

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand Down

0 comments on commit 7101ed9

Please sign in to comment.