Skip to content

Commit

Permalink
build: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wakonig committed Aug 16, 2023
1 parent 85f6c53 commit 33fadc4
Show file tree
Hide file tree
Showing 34 changed files with 926 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "scibec"]
path = scibec
url = https://gitlab.psi.ch/bec/scibec
23 changes: 23 additions & 0 deletions helm/charts/cron_chart/.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/
24 changes: 24 additions & 0 deletions helm/charts/cron_chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: cron-chart
description: A Helm chart for scheduling cron jobs

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
51 changes: 51 additions & 0 deletions helm/charts/cron_chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Cron-chart

A simple chart to deploy a cronJob runner mounting secrets

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm install my-release cron_chart
```

The command deploys a cron chart on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Parameters

The following table lists the configurable parameters of the chart and their default values.

### Common parameters

| Parameter | Description | Default |
|---------------------|----------------------------------------------------------------------|--------------------------------|
| `nameOverride` | String to partially override fullname | `nil` |
| `fullnameOverride` | String to fully override fullname | `nil` |

### cron-chart parameters

| Parameter | Description | Default |
|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| `image.repository` | Image name | `busybox` |
| `image.tag` | Image tag | `latest` |
| `image.pullPolicy` | Image pull policy | `Always` |
| `cronjob.restartPolicy` | Set the cronjob restart policy | `OnFailure` |
| `cronjob.schedule` | Set the schedule of the cronjob in the usual cron format command | `0 7 * * 1` |
| `cronjob.secret` | Name of the secret used by the cronjob to fetch env vars | `nil` |
| `secrets` | Object of objects which create secrets, in the form: { secretName:{ type:Opaque,data:{ key1:value1,key2:value2,key3:value3 } } }
| `nil` |
| `volumes` | Object of arrays with volumes to mount, in the form: https://kubernetes.io/docs/concepts/storage/volumes/#background | `nil` |
| `volumeMounts` | Object of arrays with volumes to mount and where, in the form: https://kubernetes.io/docs/concepts/storage/volumes/#background | `nil` |
6 changes: 6 additions & 0 deletions helm/charts/cron_chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1. Get the application resources by running:
$ kubectl get all -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm_chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"
2. Get the application configmaps by running:
$ kubectl get configmaps -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm_chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"
3. Get the application secrets by running:
$ kubectl get secrets -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm_chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"
74 changes: 74 additions & 0 deletions helm/charts/cron_chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "helm_chart.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 "helm_chart.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 }}
{{- .Release.Name }}
{{- end }}
{{- end }}
{{- end }}

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "helm_chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "helm_chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Validate the secret, checking if base64 encoded
*/}}
{{- define "validateSecret" -}}
{{ $secret := regexReplaceAllLiteral "\u0026#x3D;" (regexReplaceAllLiteral "\u0026#x2F;" . "/") "=" }}
{{- if (b64dec $secret | hasPrefix "illegal base64") -}}
{{ fail "Please b64 encode your secrets!" }}
{{- else }}
{{- $secret }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions helm/charts/cron_chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "helm_chart.fullname" . }}
labels:
{{- include "helm_chart.labels" $ | nindent 4 }}
spec:
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
schedule: {{ .Values.cronjob.schedule | quote }}
jobTemplate:
spec:
template:
metadata:
labels:
{{- include "helm_chart.selectorLabels" . | nindent 12 }}
spec:
restartPolicy: {{ .Values.cronjob.restartPolicy }}
{{- with .Values.initContainers }}
initContainers:
{{- toYaml . | nindent 10 }}
{{- end }}
containers:
- name: {{ include "helm_chart.fullname" . }}
image: {{ tpl .Values.image.repository $ }}:{{ tpl .Values.image.tag $ }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
{{- with .Values.volumes}}
volumes:
{{- tpl (toYaml .) $ | nindent 10 }}
{{- end }}
14 changes: 14 additions & 0 deletions helm/charts/cron_chart/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- range $name, $values := $.Values.secrets }}
apiVersion: v1
kind: Secret
metadata:
name: {{ tpl $name $ }}
labels:
{{- include "helm_chart.labels" $ | nindent 4 }}
type: {{ $values.type }}
data:
{{- range $k, $v := $values.data }}
{{ $k }}:
{{- tpl (printf "%s" $v) $ | include "validateSecret" | indent 4 }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions helm/charts/cron_chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Default values for search-api.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: "busybox"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: latest

nameOverride: ""
fullnameOverride: ""

cronjob:
restartPolicy: OnFailure
schedule: 0 7 * * 1
23 changes: 23 additions & 0 deletions helm/charts/generic_service/.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/
24 changes: 24 additions & 0 deletions helm/charts/generic_service/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: generic-service-chart
description: A Helm chart for Kubernetes to deploy a generic service. Highly configurable, app specific values can be set as files or as values

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
Loading

0 comments on commit 33fadc4

Please sign in to comment.