.
All checks were successful
Package and publish helm chart / package-helm (push) Successful in 14s

This commit is contained in:
Jonas Forsberg
2024-10-22 14:29:12 +02:00
parent d4a800e3d4
commit 0fe6d615a0
11 changed files with 99 additions and 128 deletions

View File

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

View File

@@ -21,7 +21,7 @@ spec:
{{- end }}
labels:
{{- include "lib.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- with .Values.controller.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
@@ -33,38 +33,7 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.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: {{ default $v.port $v.targetPort }}
{{- end -}}
{{- end -}}
{{- end }}
env:
{{- include "lib.environmentVariables" . | default "[]" | nindent 12 }}
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "lib.parts.container" . | nindent 8 -}}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}

View File

@@ -72,54 +72,3 @@ Merge the local chart values and the library chart defaults
{{- $_ := set . "Values" (deepCopy $mergedValues) -}}
{{- 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}}
{{- end }}
{{- end }}
---
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
@@ -20,8 +21,7 @@ metadata:
namespace: {{ .Values.namespace }}
labels:
{{- include "lib.labels" . | nindent 4 }}
{{- with .Values.ingressingresstservicePort }}
{{- $svcName := .Values.ingress.service -}}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -52,7 +52,7 @@ spec:
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}-${{ $svcName }}
name: {{ $fullName }}-{{ $svcName }}
port:
number: {{ $svcPort }}
{{- else }}

View File

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

View File

@@ -35,39 +35,7 @@ spec:
securityContext:
{{- toYaml .Values.controller.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
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 }}
{{- end -}}
{{- end -}}
{{- end }}
env:
{{- include "lib.environmentVariables" . | default "[]" | nindent 12 }}
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
{{- range $i, $values := .Values.volumeClaimTemplates }}
- name: {{ $values.name }}
mountPath: {{ $values.mountPath }}
{{- end }}
{{- include "lib.parts.container" . | nindent 8 -}}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}

View File

@@ -0,0 +1,47 @@
{{- 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 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 4 }}
{{- 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 -}}