base-cronjob
by Das Meta
A Base Helm chart for Kubernetes CronJob
About this chart
This helm chart allows to create and configure kubernetes cronjob resources, it designed in way to be able to pass list of cronjobs configs
Public values and options are documented in values.yaml. Example values files: examples/base-cronjob/ (e.g. minimal.yaml). From repo root: helm template test charts/base-cronjob -f examples/base-cronjob/minimal.yaml.
Key values
| Key | Description | Default / Example |
|---|---|---|
jobs | List of cronjob definitions | each: name, schedule, image (repository, tag), env, etc. |
jobs[].name | CronJob name | required |
jobs[].schedule | Cron schedule (e.g. "0 * * * *") | required |
jobs[].image.repository | Container image | required |
jobs[].image.tag | Image tag | latest |
jobs[].rbac | Optional Role/ClusterRole and binding for the job ServiceAccount | disabled |
jobs[].securityContext | Optional container security context | {} |
jobs[].successfulJobsHistoryLimit | Number of successful finished jobs to retain | optional |
jobs[].failedJobsHistoryLimit | Number of failed finished jobs to retain | optional |
jobs[].suspend | Suspend future CronJob runs | optional |
jobs[].jobBackoffLimit | Number of retries before marking a Job failed | optional |
jobs[].ttlSecondsAfterFinished | TTL in seconds for finished Jobs | optional |
Easy how to
Easiest option to deploy cronjob is:
helm repo add dasmeta https://dasmeta.github.io/helm/
helm upgrade --install my-cronjob dasmeta/base-cronjob \
--set jobs[0].name=my-cronjob \
--set jobs[0].image.repository=my-cronjob \
--set jobs[0].schedule="* * * * *"
Via values file
Values can be supplied via values.yaml.
jobs:
- name: cronjob1
schedule: "0 * * * *"
image:
repository: my-cronjob
helm repo add dasmeta https://dasmeta.github.io/helm/
helm upgrade --install my-cronjob dasmeta/base-cronjob -f path/to/values.yaml
As sub-chart
Alternatively base chart can be used as sub-chart.
dependencies:
- name: base
version: 0.1.36
repository: https://dasmeta.github.io/helm
Resources
Some resources are created only when you specify them. For example, set this to escape from creating an empty ConfigMap resource:
config:
enabled: false
data:
<data>
Set config.envFrom: false when the ConfigMap is mounted as files and should not be imported as environment variables.
Specify this to create ServiceAccount resource:
serviceAccount:
create: true
Set this to create RBAC for a job:
rbac:
create: true
clusterWide: true
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
Set this to have PVCs for a job:
storage:
- persistentVolumeClaimName: pvc-job1-storage1
keepPvc: true
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
requestedSize: 5Gi
className: standard
enableDataSource: false
- persistentVolumeClaimName: pvc-job1-storage2
keepPvc: false
accessModes:
- ReadWriteMany
volumeMode: Filesystem
requestedSize: 10Gi
className: standard
enableDataSource: true
Use secrets:
secrets:
- APP_NAME:
from: secret-name
key: APP_NAME
Deploy base-cronjob with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has base-cronjob on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartbase-cronjob is pinned at v0.1.40 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply