Skip to content

Commit

Permalink
[Job] Add job chart (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Misencik <[email protected]>
  • Loading branch information
SimonMisencik authored Sep 20, 2022
1 parent 9e0cde6 commit 5ca3a43
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/job/.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/
18 changes: 18 additions & 0 deletions charts/job/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: job
version: 1.0.0
description: A Helm chart for Kubernetes Job
keywords:
- job
home: https://github.com/SimonMisencik/helm-charts
sources:
- https://github.com/SimonMisencik/helm-charts
maintainers:
- name: SimonMisencik
email: [email protected]
icon: https://cdn-icons-png.flaticon.com/512/942/942800.png
appVersion: "1.0.0"
annotations:
artifacthub.io/changes: |
- kind: added
description: First release
41 changes: 41 additions & 0 deletions charts/job/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# job

A Helm chart for Kubernetes Job

## Get Repo Info

```console
helm repo add open https://simonmisencik.github.io/helm-charts
helm repo update
```

## Install Chart

```console
helm install [RELEASE_NAME] open/job
```

## Upgrading Chart

```console
helm upgrade [RELEASE_NAME] open/job
```

## Uninstall Chart

```console
helm uninstall [RELEASE_NAME]
```

## Configuration

| Parameter | Description | Default |
|-----------|-------------|---------|
| `image.repository` | Image repository | `ubuntu` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `image.tag` | Image tag | `"latest"` |
| `imagePullSecrets` | Pull secrets for images | `[]` |
| `restartPolicy` | Restart policy for job container | `OnFailure` |
| `command` | Command for container | `'["bash", "-c", "sleep 365d"]'` |
| `extraInitContainers` | extraInitContainers for job | |
| `env` | Environment variables for job container | |
1 change: 1 addition & 0 deletions charts/job/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Your job was deployed!
62 changes: 62 additions & 0 deletions charts/job/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "job.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "job.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "job.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "job.labels" -}}
helm.sh/chart: {{ include "job.chart" . }}
{{ include "job.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "job.selectorLabels" -}}
app.kubernetes.io/name: {{ include "job.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "job.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "job.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/job/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "job.fullname" . }}
labels:
{{- include "job.labels" . | nindent 4 }}
spec:
template:
spec:
restartPolicy: {{ .Values.restartPolicy }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraInitContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: {{ .Values.command }}
env:
{{- range $key, $val := .Values.env }}
- name: {{ $key | quote }}
value: {{ $val | quote }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/job/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Default values for job.

image:
repository: ubuntu
pullPolicy: IfNotPresent
tag: "latest"

imagePullSecrets: []
restartPolicy: OnFailure
command: '["bash", "-c", "sleep 365d"]'

extraInitContainers:

env:

0 comments on commit 5ca3a43

Please sign in to comment.