Skip to content

Commit

Permalink
add cronjob chart
Browse files Browse the repository at this point in the history
  • Loading branch information
kahnwong committed May 17, 2024
1 parent c1d4179 commit 376a86d
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/deploy-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,26 @@ jobs:
helm package chart
PKG_NAME=`ls *.tgz`
helm push ${PKG_NAME} oci://ghcr.io/${REPO_OWNER}/charts
deploy-chart-cronjob:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://gist.github.com/t83714/2a5e597e94053856e78257efe59003a3/raw/babc804cada53589f749ad4ac22091a5c38620a1/release.yaml
- name: Pushing Helm Chart
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
cd kubernetes/charts/base
helm package chart-cronjob
PKG_NAME=`ls *.tgz`
helm push ${PKG_NAME} oci://ghcr.io/${REPO_OWNER}/charts
23 changes: 23 additions & 0 deletions kubernetes/charts/base/chart-cronjob/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions kubernetes/charts/base/chart-cronjob/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: v2
name: base-cronjob
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
6 changes: 6 additions & 0 deletions kubernetes/charts/base/chart-cronjob/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Values.name | trunc 63 | trimSuffix "-" }}
{{- end }}
30 changes: 30 additions & 0 deletions kubernetes/charts/base/chart-cronjob/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ template "name" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
schedule: {{ .Values.schedule }}
jobTemplate:
metadata:
name: {{ template "name" . }}
spec:
template:
spec:
containers:
{{ range .Values.containers }}
- name: {{ .name }}
image: "{{ .repository }}:{{ .tag }}"
command: {{ .command | default list | toYaml | nindent 16 }}
args: {{ .args | default list | toYaml | nindent 16 }}
env: {{ .env | default list | toYaml | nindent 16 }}
envFrom: {{ .envFrom | default list | toYaml | nindent 16 }}
volumeMounts: {{ toYaml .volumeMounts | default list | nindent 16 }}
{{ end }}
restartPolicy: Never
volumes: {{ toYaml .Values.volumes | default list | nindent 12 }}
tolerations: {{ toYaml .Values.tolerations | default list | nindent 12 }}
{{ if .Values.nodeSelector }}
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 12 }}
{{ end }}
4 changes: 2 additions & 2 deletions kubernetes/charts/base/chart/templates/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
{{ if .command }}
command: {{ .command }}
{{ end }}
{{ if .args }}
{{ if .args }} # dupe
args: {{ .args }}
{{ end }}
{{ if .port }}
Expand All @@ -53,7 +53,7 @@ spec:
port: {{ .port }}
{{ end }}
securityContext: {{ toYaml .securityContext | default list | nindent 14 }}
args: {{ .args | default list | toYaml | nindent 14 }}
args: {{ .args | default list | toYaml | nindent 14 }} # dupe
env: {{ .env | default list | toYaml | nindent 14 }}
envFrom: {{ .envFrom | default list | toYaml | nindent 14 }}
resources: {{ toYaml .resources | default list | nindent 14 }}
Expand Down

0 comments on commit 376a86d

Please sign in to comment.