-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from WyriHaximusNet/add-cron-jobs-library-chart
Add cron-jobs library chart
- Loading branch information
Showing
9 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,11 @@ jobs: | |
installLocalPathProvisioner: true | ||
# Only build a kind cluster if there are chart changes to test. | ||
|
||
- name: Prepare library charts | ||
run: | | ||
cp charts/cron-jobs/library-ci/*.yaml charts/cron-jobs/templates/ | ||
sed -i 's/library/application/g' charts/cron-jobs/Chart.yaml | ||
- name: Test charts | ||
uses: helm/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v2 | ||
name: cron-jobs | ||
description: CronJobs library | ||
home: https://github.com/wyrihaximusnet/helm-charts | ||
icon: https://helm.wyrihaximus.net/images/charts/cron-jobs.png | ||
type: library | ||
version: 0.1.0 | ||
maintainers: | ||
- name: WyriHaximus | ||
email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Cron Jobs | ||
|
||
Opinionated helm library chart for easy creation of cron jobs. | ||
|
||
# Example | ||
|
||
Very basic example without any customization: | ||
|
||
```gotemplate | ||
{{- range $job := .Values.jobs }} | ||
{{- include "cron-jobs.cronjob" $job -}} | ||
{{- end }} | ||
``` | ||
|
||
The following values will run a cronjob that sleeps for 1 second any minute | ||
|
||
```yaml | ||
jobs: | ||
- name: sleep | ||
schedule: "* * * * *" | ||
labels: | ||
cronjob: | ||
key: value | ||
jobTemplate: | ||
key: value | ||
container: | ||
command: ["sleep"] | ||
args: ["1"] | ||
resources: | ||
limits: | ||
cpu: 1m | ||
memory: 12Mi | ||
requests: | ||
cpu: 1m | ||
memory: 12Mi | ||
image: | ||
repository: alpine | ||
tag: 3.12 | ||
pullPolicy: IfNotPresent | ||
``` | ||
## Opinionated decisions | ||
* A history of `3` failed and `3` successful jobs are kept around for log checking. | ||
* No restarts | ||
* No concurrently | ||
* A single container per cron job | ||
* `cron` and `name` labels are set on each cron job with the name you give it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
jobs: | ||
- name: sleep | ||
schedule: "* * * * *" | ||
labels: | ||
cronjob: | ||
key: value | ||
jobTemplate: | ||
key: value | ||
container: | ||
command: ["sleep"] | ||
args: ["1"] | ||
resources: | ||
limits: | ||
cpu: 1m | ||
memory: 12Mi | ||
requests: | ||
cpu: 1m | ||
memory: 12Mi | ||
image: | ||
repository: alpine | ||
tag: 3.12 | ||
pullPolicy: IfNotPresent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{- range $job := .Values.jobs }} | ||
{{- include "cron-jobs.cronjob" $job -}} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{{- define "cron-jobs.cronjob" }} | ||
--- | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: "{{ .name }}" | ||
labels: | ||
name: {{ .name }} | ||
cron: {{ .name }} | ||
{{- with .labels.cronjob }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
schedule: {{ .schedule | quote }} | ||
concurrencyPolicy: Forbid | ||
failedJobsHistoryLimit: 3 | ||
successfulJobsHistoryLimit: 3 | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
name: {{ .name }} | ||
cron: {{ .name }} | ||
{{- with .labels.jobTemplate }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
spec: | ||
{{- with .spec }} | ||
{{- toYaml . | nindent 10 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ .name }} | ||
image: "{{ .image.repository }}:{{ .image.tag }}" | ||
imagePullPolicy: {{ .image.imagePullPolicy }} | ||
{{- with .container }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
restartPolicy: Never | ||
{{- end }} |
Empty file.