43 Commits

Author SHA1 Message Date
Jonas Forsberg
9bd4849df7 changed token variable 2024-11-11 15:51:48 +01:00
6885f46027 Merge pull request 'added helm back' (#9) from fix_build into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 8s
Package and publish helm chart / package-helm (push) Successful in 13s
Reviewed-on: #9
2024-11-11 10:02:17 +00:00
Jonas Forsberg
0d9a47f208 added helm back 2024-11-11 11:01:57 +01:00
e211d43dc7 Merge pull request 'fix_stateful' (#8) from fix_stateful into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 10s
Reviewed-on: #8
fixes #7
2024-11-11 09:55:52 +00:00
Jonas Forsberg
224c1ccd2f changed to gitea helm repo
Some checks failed
Package and publish helm chart / package-helm (push) Failing after 11s
2024-11-11 10:55:03 +01:00
Jonas Forsberg
f924f986a9 fixed volumeMounts for statefulset 2024-11-11 09:38:40 +01:00
2ae5f80aa4 Merge pull request 'fixed verion tag' (#6) from version_fix into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
Package and publish helm chart / package-helm (push) Successful in 15s
Reviewed-on: #6
2024-10-22 14:15:06 +00:00
Jonas Forsberg
db1b814416 fixed verion tag 2024-10-22 16:14:33 +02:00
8753852318 Merge pull request 'fixed namespace' (#5) from deployment-ns into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 8s
Package and publish helm chart / package-helm (push) Successful in 14s
Reviewed-on: #5
2024-10-22 14:08:47 +00:00
Jonas Forsberg
fef72ffc1a fixed namespace 2024-10-22 16:08:06 +02:00
35fbb3534e Merge pull request 'deployment' (#3) from deployment into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 9s
Reviewed-on: #3
2024-10-22 12:30:56 +00:00
Jonas Forsberg
0fe6d615a0 .
All checks were successful
Package and publish helm chart / package-helm (push) Successful in 14s
2024-10-22 14:29:12 +02:00
Jonas Forsberg
d4a800e3d4 . 2024-10-19 11:30:12 +02:00
Jonas Forsberg
04aa844ce6 . 2024-10-19 11:29:25 +02:00
Jonas Forsberg
4f2a9ba9b7 . 2024-10-19 11:23:43 +02:00
Jonas Forsberg
dd11ed2197 fixed default varable 2024-10-19 11:09:04 +02:00
Jonas Forsberg
817fdf175a added deployment 2024-10-19 11:00:59 +02:00
3cd2466816 Merge pull request 'hooks' (#2) from hooks into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 9s
Reviewed-on: #2
2024-10-19 06:55:27 +00:00
Jonas Forsberg
5b8b037905 . 2024-10-19 08:54:28 +02:00
Jonas Forsberg
088ce48d6c fixed pre-commit 2024-10-19 08:53:12 +02:00
cf63ca5dc5 Merge pull request 'added *.tgz' (#1) from jonas-patch-1 into main
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
Reviewed-on: #1
2024-10-18 14:46:59 +00:00
5ec2a72505 added *.tgz 2024-10-18 14:46:49 +00:00
Jonas Forsberg
82caca32d4 removed hardcoded version in example
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 16:42:00 +02:00
Jonas Forsberg
0204cc88db added env.TZ default value
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 16:39:39 +02:00
Jonas Forsberg
f7fd24fe6f fixed trailing whitespaces
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 16:24:24 +02:00
Jonas Forsberg
bc9963a6ca added init
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 16:02:44 +02:00
Jonas Forsberg
9222a6f811 added githooks
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 16:01:00 +02:00
Jonas Forsberg
4f5f14adfc fixed repository entry
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 15:39:20 +02:00
Jonas Forsberg
e596c93931 wrong step id used
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
Package and publish helm chart / package-helm (push) Successful in 14s
2024-10-18 15:32:29 +02:00
Jonas Forsberg
d3c3107491 removed echo statement
Some checks failed
Package and publish helm chart / package-helm (push) Failing after 14s
2024-10-18 15:29:50 +02:00
Jonas Forsberg
174835f9fc fixed variables
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
Package and publish helm chart / package-helm (push) Successful in 13s
2024-10-18 15:23:09 +02:00
Jonas Forsberg
0f4336caf9 fixed correct yq
Some checks failed
Lint and Test Charts / lint-test (push) Successful in 7s
Lint and Test Charts / package-helm (push) Failing after 19s
2024-10-18 15:06:16 +02:00
Jonas Forsberg
5a4b3d7612 added yq repo
Some checks failed
Lint and Test Charts / lint-test (push) Successful in 7s
Lint and Test Charts / package-helm (push) Failing after 27s
2024-10-18 14:50:43 +02:00
Jonas Forsberg
0cf4704fd2 .
Some checks failed
Lint and Test Charts / lint-test (push) Successful in 7s
Lint and Test Charts / package-helm (push) Failing after 17s
2024-10-18 14:41:56 +02:00
Jonas Forsberg
3610963a9e correct packate syntax
Some checks failed
Lint and Test Charts / lint-test (push) Failing after 7s
2024-10-18 14:28:09 +02:00
Jonas Forsberg
8de903f860 added tag pipeline
Some checks failed
Lint and Test Charts / lint-test (push) Failing after 12s
2024-10-18 14:21:00 +02:00
Jonas Forsberg
5942d11624 set the default imagePullPolicy to IfNotPresent
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 8s
2024-10-18 11:04:28 +02:00
Jonas Forsberg
b2ea2d9f0c changed title on lint step
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 7s
2024-10-18 10:27:57 +02:00
Jonas Forsberg
e9cca5c631 added frigate template
All checks were successful
Lint and Test Charts / lint-test (push) Successful in 9s
2024-10-18 10:26:05 +02:00
Jonas Forsberg
7fff421620 correkted the workflows name 2024-10-18 09:49:17 +02:00
Jonas Forsberg
deeeb10366 secrets/configmaps added 2024-10-18 09:45:08 +02:00
Jonas Forsberg
ce53a03d54 moved comments to fit frigate 2024-10-18 09:30:07 +02:00
Jonas Forsberg
25dafc3c82 added pre-commit hooks 2024-10-18 09:27:50 +02:00
22 changed files with 346 additions and 127 deletions

19
.frigate Normal file
View File

@@ -0,0 +1,19 @@
{% extends "markdown.jinja2" %}
{% block title -%}
# {{ name | upper }}
to use, add this to your Charts.yaml
```
dependencies:
- name: lib
repository: oci://repo.rre.nu/helm
version: <chart version>
```
{%- endblock %}

View File

@@ -0,0 +1,43 @@
name: Package and publish helm chart
on:
push:
# Pattern matched against refs/tags
tags:
- '**' # Push events to every tag including hierarchical tags like v1.0/beta
jobs:
package-helm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out code
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.14.4
- name: Get package name
id: chart_name
uses: mikefarah/yq@master
with:
cmd: yq .name Chart.yaml
- name: Get package version
id: chart_version
uses: mikefarah/yq@master
with:
cmd: yq .version Chart.yaml
- name: build helm package
shell: bash
env:
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
CHART_NAME: ${{ steps.chart_name.outputs.result }}
CHART_VERSION: ${{ steps.chart_version.outputs.result }}
run: |
REPO_PATH=$(git rev-parse --show-toplevel)
mkdir /tmp/build
cd /tmp/build
helm package $REPO_PATH
curl -H "Authorization: token $PACKAGE_TOKEN" -X POST --upload-file ${CHART_NAME}-${CHART_VERSION}.tgz https://git.rre.nu/api/packages/jonas/helm/api/charts

View File

@@ -19,7 +19,7 @@ jobs:
with: with:
version: v3.14.4 version: v3.14.4
- name: List all changed files - name: Lint the helm package
env: env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: | run: |

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@ bin/*
.project .project
/.bin /.bin
/_test/secrets/*.json /_test/secrets/*.json
*.tgz
# OSX leaves these everywhere on SMB shares # OSX leaves these everywhere on SMB shares
._* ._*

View File

@@ -21,3 +21,4 @@
.idea/ .idea/
*.tmproj *.tmproj
.vscode/ .vscode/
*.tgz

20
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: ^README.md$
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/rapidsai/frigate/
rev: v0.4.0
hooks:
- id: frigate
args:
- --output=README.rst
- --format=rst
- --no-credits
- --no-deps

6
CHANGES.md Normal file
View File

@@ -0,0 +1,6 @@
# next
- added env.TZ to default to Europe/Stockholm
- added deployment type
# v1.0.0
- first version

View File

@@ -3,7 +3,7 @@ apiVersion: v2
name: lib name: lib
description: Common functions for my helm charts at home description: Common functions for my helm charts at home
type: library type: library
version: 1.0.0 version: 1.0.3
kubeVersion: ">=1.27.0" kubeVersion: ">=1.27.0"
home: git.rre.nu home: git.rre.nu
sources: sources:

View File

@@ -1,5 +1,10 @@
NEW_VERSION:=$(shell yq '.version |= (split(".") | .[-1] |= ((. tag = "!!int") + 1) | join("."))' Chart.yaml | yq '.version') NEW_VERSION:=$(shell yq '.version |= (split(".") | .[-1] |= ((. tag = "!!int") + 1) | join("."))' Chart.yaml | yq '.version')
pre-commit:
pip install pre-commit
pre-commit install
branch: branch:
@echo "New chart version is: $(NEW_VERSION)" @echo "New chart version is: $(NEW_VERSION)"
git checkout -b lib_$(NEW_VERSION) git checkout -b lib_$(NEW_VERSION)

68
README.md Normal file
View File

@@ -0,0 +1,68 @@
# LIB
to use, add this to your Charts.yaml
```
dependencies:
- name: lib
repository: oci://repo.rre.nu/helm
version: <chart version>
```
Common functions for my helm charts at home
## Configuration
The following table lists the configurable parameters of the Lib chart and their default values.
| Parameter | Description | Default |
| ------------------------ | ----------------------- | -------------- |
| `namespace` | namespace to install to | `"default"` |
| `controller.enabled` | should the main workload be included or not | `true` |
| `controller.type` | valid options are deployment, statefulset, job | `"deployment"` |
| `controller.replicas` | number of replicas | `1` |
| `controller.lifecycle` | Define postStart and preStop handlers | `{}` |
| `controller.command` | override the containers entrypoint | `null` |
| `controller.args` | add argument to the override command | `[]` |
| `image.repository` | container image name | `null` |
| `image.pullPolicy` | kubernetes pull policy | `"IfNotPresent"` |
| `image.tag` | Overrides the image tag whose default is the chart appVersion. | `""` |
| `fullnameOverride` | override the name of the helm release | `""` |
| `service.main.enabled` | | `false` |
| `service.main.type` | | `"ClusterIP"` |
| `service.main.annotations` | | `{}` |
| `service.main.labels` | | `{}` |
| `service.main.ports` | | `null` |
| `ingress.enabled` | | `false` |
| `ingress.service` | what service should the ingress target | `"main"` |
| `ingress.servicePort` | | `80` |
| `ingress.className` | | `""` |
| `ingress.annotations` | | `{}` |
| `ingress.hosts` | | `[{"host": "chart-example.local", "paths": [{"path": "/", "pathType": "ImplementationSpecific"}]}]` |
| `ingress.tls` | | `[]` |
| `resources` | | `{}` |
| `autoscaling.enabled` | | `false` |
| `autoscaling.minReplicas` | | `1` |
| `autoscaling.maxReplicas` | | `5` |
| `autoscaling.targetCPUUtilizationPercentage` | | `80` |
| `secrets` | Secrets that needs to be created | `{}` |
| `configs` | ConfigMaps that needs to be created | `{}` |
| `envFrom` | mount environment variables from secrets or configMaps | `[]` |
| `env.TZ` | | `"Europe/Stockholm"` |
| `volumes` | | `[]` |
| `volumeMounts` | | `[]` |
| `volumeClaimTemplates` | used for statefulset https://kubernetes.io/docs/concepts/workloads/controllers/statefulset | `[]` |
| `serviceAccount.create` | | `true` |
| `serviceAccount.automount` | | `true` |
| `serviceAccount.annotations` | | `{}` |
| `serviceAccount.name` | | `""` |
| `livenessProbe` | | `{}` |
| `readinessProbe` | | `{}` |
| `nodeSelector` | | `{}` |
| `tolerations` | | `[]` |
| `affinity` | | `{}` |

View File

@@ -14,9 +14,9 @@ Main entrypoint for the common library chart. It will render all underlying temp
{{ include "lib.configs" . | nindent 0 }} {{ include "lib.configs" . | nindent 0 }}
{{ if .Values.controller.enabled }} {{ if .Values.controller.enabled }}
{{ if eq .Values.controller.type "statefulset" }} {{ if eq .Values.controller.type "statefulset" }}
{{- include "lib.statefulset" . | nindent 0}} {{- include "lib.statefulset" . | nindent 0 }}
{{ else if eq .Values.controller.type "deployment" }}
{{- include "lib.deployment" . | nindent 0 }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View File

@@ -1,6 +1,6 @@
{{- define "lib.configs" -}} {{- define "lib.configs" -}}
{{- $fullName := include "lib.fullname" . -}} {{- $fullName := include "lib.fullname" . -}}
{{- $namespace := .Values.namespace -}} {{- $namespace := .Values.namespace | default "default" -}}
{{- $commonLabels := include "lib.labels" . }} {{- $commonLabels := include "lib.labels" . }}
{{- range $name, $values := .Values.configs }} {{- range $name, $values := .Values.configs }}
{{- if $values.enabled -}} {{- if $values.enabled -}}
@@ -25,4 +25,4 @@ data:
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

54
templates/_deployment.tpl Normal file
View File

@@ -0,0 +1,54 @@
{{- define "lib.deployment" -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "lib.fullname" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "lib.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "lib.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "lib.labels" . | nindent 8 }}
{{- with .Values.controller.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "lib.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
{{- include "lib.parts.container" . | nindent 8 -}}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

View File

@@ -61,8 +61,8 @@ Create the name of the service account to use
{{- end }} {{- end }}
{{- end }} {{- end }}
{{/* {{/*
Merge the local chart values and the library chart defaults Merge the local chart values and the library chart defaults
*/}} */}}
{{- define "lib.values.setup" -}} {{- define "lib.values.setup" -}}
{{- if .Values.lib -}} {{- if .Values.lib -}}
@@ -72,54 +72,3 @@ Merge the local chart values and the library chart defaults
{{- $_ := set . "Values" (deepCopy $mergedValues) -}} {{- $_ := set . "Values" (deepCopy $mergedValues) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{/*
Get all environment variables and
secrets that should be mounted as environment variables
*/}}
{{- define "lib.environmentVariables" -}}
{{- $envIncluded := "false" -}}
{{- $fullName := include "lib.fullname" . -}}
{{- range $name, $settings := .Values.secrets -}}
{{- if $settings.enabled -}}
{{- if $settings.env -}}
{{- $envIncluded := "true" -}}
{{- range $key, $value := $settings.data }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ $fullName }}-{{ $name }}
key: {{ $key }}
{{- end -}}
{{- range $key, $value := $settings.stringData }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ $fullName }}-{{ $name }}
key: {{ $key }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range $name, $settings := .Values.configs -}}
{{- if $settings.enabled -}}
{{- if $settings.env -}}
{{- $envIncluded := "true" -}}
{{- range $key, $value := $settings.data }}
- name: {{ $key }}
valueFrom:
configMapKeyRef:
name: {{ $fullName }}-{{ $name }}
key: {{ $key }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $envIncluded = "true" -}}
{{- if .Values.env -}}
{{- toYaml .Values.env | nindent 0 -}}
{{- end -}}
{{- else -}}
{{- toYaml .Values.env | nindent 0 -}}
{{- end -}}
{{- end -}}

View File

@@ -7,6 +7,7 @@
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }} {{- end }}
{{- end }} {{- end }}
---
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
@@ -20,8 +21,7 @@ metadata:
namespace: {{ .Values.namespace }} namespace: {{ .Values.namespace }}
labels: labels:
{{- include "lib.labels" . | nindent 4 }} {{- include "lib.labels" . | nindent 4 }}
{{- with .Values.ingressingresstservicePort }} {{- with .Values.ingress.annotations }}
{{- $svcName := .Values.ingress.service -}}
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
@@ -52,7 +52,7 @@ spec:
backend: backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service: service:
name: {{ $fullName }}-${{ $svcName }} name: {{ $fullName }}-{{ $svcName }}
port: port:
number: {{ $svcPort }} number: {{ $svcPort }}
{{- else }} {{- else }}

View File

@@ -1,6 +1,6 @@
{{- define "lib.secrets" -}} {{- define "lib.secrets" -}}
{{- $fullName := include "lib.fullname" . -}} {{- $fullName := include "lib.fullname" . -}}
{{- $namespace := .Values.namespace -}} {{- $namespace := .Values.namespace | default "default" -}}
{{- $commonLabels := include "lib.labels" . }} {{- $commonLabels := include "lib.labels" . }}
{{- range $name, $values := .Values.secrets }} {{- range $name, $values := .Values.secrets }}
{{- if $values.enabled -}} {{- if $values.enabled -}}
@@ -30,4 +30,4 @@ stringData:
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View File

@@ -14,16 +14,16 @@ metadata:
labels: labels:
{{- $labels | nindent 4 }} {{- $labels | nindent 4 }}
spec: spec:
type: {{ $values.type }} type: {{ default "ClusterIP" $values.type }}
ports: ports:
{{- range $k, $v := $values.ports }} {{- range $k, $v := $values.ports }}
- port: {{ $v.port }} - port: {{ $v.port }}
targetPort: {{ default $v.targetPort $v.port }} targetPort: {{ default $v.port $v.targetPort }}
protocol: {{ $v.protocol }} protocol: {{ default "TCP" $v.protocol }}
name: {{ $k }} name: {{ $k }}
{{- end }} {{- end }}
selector: selector:
{{- $selectorlabels | nindent 4 }} {{- $selectorlabels | nindent 4 }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View File

@@ -12,4 +12,4 @@ metadata:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }} automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }} {{- end }}

View File

@@ -35,34 +35,7 @@ spec:
securityContext: securityContext:
{{- toYaml .Values.controller.podSecurityContext | nindent 8 }} {{- toYaml .Values.controller.podSecurityContext | nindent 8 }}
containers: containers:
- name: {{ .Chart.Name }} {{- include "lib.parts.container" . | nindent 8 -}}
securityContext:
{{- toYaml .Values.controller.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
{{- range $name, $values := .Values.service -}}
{{- if $values.enabled -}}
{{- range $k, $v := $values.ports }}
- name: {{ $k }}
containerPort: {{ $v.targetPort | default $v.port }}
protocol: {{ $v.protocol }}
{{- end -}}
{{- end -}}
{{- end }}
env:
{{- include "lib.environmentVariables" . | default "[]" | nindent 12 }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- range $i, $values := .Values.volumeClaimTemplates }}
- name: {{ $values.name }}
mountPath: {{ $values.mountPath }}
{{- end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}

View File

@@ -0,0 +1,53 @@
{{- define "lib.parts.container" -}}
{{/*
create the environment varable list
*/}}
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 4 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.controller.command }}
command: {{ toYaml . | nindent 4}}
{{- end }}
{{- with .Values.controller.args }}
args: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.controller.lifecycle }}
lifecycle:
{{- toYaml . | nindent 4 }}
{{- end }}
ports:
{{- range $name, $values := .Values.service -}}
{{- if $values.enabled -}}
{{- range $k, $v := $values.ports }}
- name: {{ $k }}
containerPort: {{ default $v.port $v.targetPort }}
{{- end -}}
{{- end -}}
{{- end }}
env:
{{- include "lib.parts.env" . | nindent 4 -}}
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if or .Values.volumeMounts .Values.volumeClaimTemplates }}
volumeMounts:
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- range $v := .Values.volumeClaimTemplates }}
- name: {{ $v.name }}
mountPath: {{ $v.mountPath }}
{{- end }}
{{- end }}

26
templates/parts/_env.tpl Normal file
View File

@@ -0,0 +1,26 @@
{{/*
Get all environment variables configMaps and
secrets that should be mounted as environment variables
*/}}
{{- define "lib.parts.env" -}}
{{/*
environment variables from .Values.env
*/}}
{{- range $name, $value := .Values.env -}}
{{- printf "- name: %s" $name | nindent 0 }}
{{- printf "value: %s" $value | nindent 2 }}
{{- end -}}
{{/*
environment variables from configMaps
*/}}
{{- range $cfgName, $settings := .Values.configs -}}
{{- if and $settings.enabled $settings.env -}}
{{- range $key, $value := $settings.data -}}
{{- printf "- name: %s" $key | nindent 0 }}
{{- printf "valueFrom:" | nindent 2 }}
{{- printf "configMapKeyRef:" | nindent 4 }}
{{- printf "name: %s" $key | nindent 5 }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}

View File

@@ -1,24 +1,23 @@
--- ---
namespace: default namespace: default # namespace to install to
controller: controller: # main workload
# -- enable the controller enabled: true # should the main workload be included or not
enabled: true type: deployment # valid options are deployment, statefulset, job
# type of controller replicas: 1 # number of replicas
# valid options are deployment, statefulset, job lifecycle: {} # Define postStart and preStop handlers
type: deployment command: # override the containers entrypoint
replicas: 1 args: [] # add argument to the override command
image: image:
repository: repository: # container image name
pullPolicy: pullPolicy: IfNotPresent # kubernetes pull policy
# Overrides the image tag whose default is the chart appVersion. tag: "" # Overrides the image tag whose default is the chart appVersion.
tag: ""
fullnameOverride: "" fullnameOverride: "" # override the name of the helm release
service: service: # services that should be created
main: main:
enabled: true enabled: false
type: ClusterIP type: ClusterIP
annotations: {} annotations: {}
labels: {} labels: {}
@@ -46,7 +45,7 @@ service:
ingress: ingress:
enabled: false enabled: false
service: main service: main # what service should the ingress target
#Service to target #Service to target
servicePort: 80 servicePort: 80
className: "" className: ""
@@ -64,8 +63,7 @@ ingress:
# hosts: # hosts:
# - chart-example.local # - chart-example.local
resources: resources: {}
{}
# We usually recommend not to specify default resources and to leave this as a conscious # We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little # choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following # resources, such as Minikube. If you do want to specify resources, uncomment the following
@@ -84,28 +82,32 @@ autoscaling:
targetCPUUtilizationPercentage: 80 targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80
# Secrets that needs to be created secrets: {} # Secrets that needs to be created
secrets: {}
# secrets: # secrets:
# <name>: # <name>:
# type: #default Opaque # type: #default Opaque
# annotations: {} # annotations: {}
# labels: {} # labels: {}
# env: false #should template load each key in the seacret as
# data: # data:
# KEY: VALUE # KEY: VALUE
# ConfigMaps that needs to be created configs: {} # ConfigMaps that needs to be created
configs: {}
# configs: # configs:
# <name>: # <name>:
# enabled: false # should the configMap be created or not
# annotations: {} # annotations: {}
# labels: {} # labels: {}
# env: false #should template load each key in the seacret as
# data: # data:
# KEY: VALUE # KEY: VALUE
env: {} envFrom: [] # mount environment variables from secrets or configMaps
# - configMapRef:
# name: config-map-name
# - secretRef:
# name: secret-name
env: # environment variables the controller should have
TZ: Europe/Stockholm
# Additional volumes on the output Deployment definition. # Additional volumes on the output Deployment definition.
volumes: [] volumes: []
@@ -120,8 +122,7 @@ volumeMounts: []
# mountPath: "/etc/foo" # mountPath: "/etc/foo"
# readOnly: true # readOnly: true
# used for statefulset https://kubernetes.io/docs/concepts/workloads/controllers/statefulset volumeClaimTemplates: [] # used for statefulset https://kubernetes.io/docs/concepts/workloads/controllers/statefulset
volumeClaimTemplates: []
#volumeClaimTemplates: #volumeClaimTemplates:
# - name: www # - name: www
# mountPath: /var/www/html # mountPath: /var/www/html