Skip to content

Commit

Permalink
Daco2Ego as cronjob (#231)
Browse files Browse the repository at this point in the history
* Daco2Ego as cronjob

* Remove unused values

* Fix linting errors

* Daco2Ego cronjob chart published as 1.0.0
  • Loading branch information
joneubank authored Jun 19, 2024
1 parent 73ba91a commit e5732ff
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 258 deletions.
8 changes: 4 additions & 4 deletions daco2ego/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for daco2ego
apiVersion: v2
description: Run the daco2ego script as a cronjob
name: daco2ego
version: 0.1.0
version: 1.0.0
appVersion: "1.0"
21 changes: 0 additions & 21 deletions daco2ego/templates/NOTES.txt

This file was deleted.

61 changes: 46 additions & 15 deletions daco2ego/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,61 @@
Expand the name of the chart.
*/}}
{{- define "daco2ego.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- 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 "daco2ego.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 -}}
{{- 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 "daco2ego.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "daco2ego.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "daco2ego.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions daco2ego/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1

kind: ConfigMap
metadata:
name: daco2ego

data:
daco2ego.sh: |-
{{ .Files.Get "daco2ego.sh" | indent 4 }}
46 changes: 46 additions & 0 deletions daco2ego/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "daco2ego.fullname" . }}
labels:
{{- include "daco2ego.labels" . | nindent 4 }}
spec:
concurrencyPolicy: Forbid
schedule: {{ .Values.schedule }}
jobTemplate:
spec:
template:
metadata:
labels:
{{- include "daco2ego.labels" . | nindent 12 }}
{{- with .Values.extraLabels }}
{{ toYaml . | nindent 12 }}
{{- end }}
spec:
containers:
- name: backup
image: {{ .Values.image.name }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: config-file
mountPath: /daco2ego/config/default.conf
readOnly: true
env:
{{- if .Values.extraEnv }}
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- with .Values.extraEnvYaml }}
{{- toYaml . | nindent 14 }}
{{- end }}
restartPolicy: Never
serviceAccountName: {{ include "daco2ego.serviceAccountName" . }}
tolerations:
- effect: NoSchedule
operator: Exists
volumes:
- name: config-file
secret:
secretName: daco2ego-config-file
60 changes: 0 additions & 60 deletions daco2ego/templates/deployment.yaml

This file was deleted.

60 changes: 0 additions & 60 deletions daco2ego/templates/ingress.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions daco2ego/templates/rbac-crb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.authDelegator.enable }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "daco2ego.fullname" . }}
labels:
{{- include "daco2ego.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: {{ include "daco2ego.serviceAccountName" . }}
namespace: {{ $.Release.Namespace }}
{{- end}}
25 changes: 0 additions & 25 deletions daco2ego/templates/rbac.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions daco2ego/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
password: {{ .Values.configFileContent | b64enc | quote }}
kind: Secret
metadata:
name: daco2ego-config-file
type: Opaque
19 changes: 0 additions & 19 deletions daco2ego/templates/service.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions daco2ego/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "daco2ego.serviceAccountName" . }}
labels:
{{- include "daco2ego.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit e5732ff

Please sign in to comment.