mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 16:37:04 +02:00
feat(common): Release version 1.2.0 (#92)
* fix(common): fix incorrect route default values (#91) * fix(common): make `sectionName` optional for route parentRefs * fix(common): name primary route correctly * feat(common): add controller.type of cronjob (#87) * fix(common): Fix invalid persistence type message (#85) * feat(common): Allow setting container restartPolicy Co-authored-by: András Maróy <andras@maroy.hu> Co-authored-by: loeken <loeken@internetz.me> Co-authored-by: Han Cen <hi@chamburr.com>
This commit is contained in:
parent
8f2a1ba9b4
commit
72670526a3
26 changed files with 351 additions and 66 deletions
43
charts/library/common/templates/classes/_cronjob.tpl
Normal file
43
charts/library/common/templates/classes/_cronjob.tpl
Normal file
|
@ -0,0 +1,43 @@
|
|||
{{/*
|
||||
This template serves as a blueprint for Cronjob objects that are created
|
||||
using the common library.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.class.cronjob" -}}
|
||||
{{- $restartPolicy := default "Never" .Values.controller.restartPolicy -}}
|
||||
{{- if and (ne $restartPolicy "Never") (ne $restartPolicy "OnFailure") -}}
|
||||
{{- fail (printf "Not a valid restartPolicy for CronJob (%s)" $restartPolicy) -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set .Values.controller "restartPolicy" $restartPolicy -}}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
|
||||
labels: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
|
||||
annotations: {{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
concurrencyPolicy: "{{ .Values.controller.cronjob.concurrencyPolicy }}"
|
||||
startingDeadlineSeconds: {{ .Values.controller.cronjob.startingDeadlineSeconds }}
|
||||
schedule: "{{ .Values.controller.cronjob.schedule }}"
|
||||
successfulJobsHistoryLimit: {{ .Values.controller.cronjob.successfulJobsHistory }}
|
||||
failedJobsHistoryLimit: {{ .Values.controller.cronjob.failedJobsHistory }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 12 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "bjw-s.common.lib.controller.pod" . | nindent 10 }}
|
||||
{{- end -}}
|
|
@ -42,7 +42,9 @@ spec:
|
|||
kind: {{ default "Gateway" .kind }}
|
||||
name: {{ required (printf "parentRef name is required for %v %v" $routeKind $fullName) .name }}
|
||||
namespace: {{ required (printf "parentRef namespace is required for %v %v" $routeKind $fullName) .namespace }}
|
||||
sectionName: {{ default "" .sectionName | quote}}
|
||||
{{- if .sectionName }}
|
||||
sectionName: {{ .sectionName | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $values.hostnames }}
|
||||
hostnames:
|
||||
|
|
|
@ -102,4 +102,7 @@ topologySpreadConstraints:
|
|||
tolerations:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- with .Values.controller.restartPolicy }}
|
||||
restartPolicy: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
|
|
@ -61,7 +61,7 @@ Volumes included by the controller.
|
|||
{{- else if eq $persistence.type "custom" }}
|
||||
{{- toYaml $persistence.volumeSpec | nindent 2 }}
|
||||
{{- else }}
|
||||
{{- fail (printf "Not a valid persistence.type (%s)" .Values.persistence.type) }}
|
||||
{{- fail (printf "Not a valid persistence.type (%s)" $persistence.type) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
21
charts/library/common/templates/lib/routes/_primary.tpl
Normal file
21
charts/library/common/templates/lib/routes/_primary.tpl
Normal file
|
@ -0,0 +1,21 @@
|
|||
{{/* Return the name of the primary route object */}}
|
||||
{{- define "bjw-s.common.lib.route.primary" -}}
|
||||
{{- $enabledRoutes := dict -}}
|
||||
{{- range $name, $route := .Values.route -}}
|
||||
{{- if $route.enabled -}}
|
||||
{{- $_ := set $enabledRoutes $name . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $result := "" -}}
|
||||
{{- range $name, $route := $enabledRoutes -}}
|
||||
{{- if and (hasKey $route "primary") $route.primary -}}
|
||||
{{- $result = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $result -}}
|
||||
{{- $result = keys $enabledRoutes | first -}}
|
||||
{{- end -}}
|
||||
{{- $result -}}
|
||||
{{- end -}}
|
|
@ -5,6 +5,8 @@ Renders the controller object required by the chart.
|
|||
{{- if .Values.controller.enabled -}}
|
||||
{{- if eq .Values.controller.type "deployment" -}}
|
||||
{{- include "bjw-s.common.class.deployment" . | nindent 0 -}}
|
||||
{{- else if eq .Values.controller.type "cronjob" -}}
|
||||
{{- include "bjw-s.common.class.cronjob" . | nindent 0 -}}
|
||||
{{ else if eq .Values.controller.type "daemonset" -}}
|
||||
{{- include "bjw-s.common.class.daemonset" . | nindent 0 -}}
|
||||
{{ else if eq .Values.controller.type "statefulset" -}}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{{- $routeValues := $route -}}
|
||||
|
||||
{{/* set defaults */}}
|
||||
{{- if not $routeValues.nameOverride -}}
|
||||
{{- if and (not $routeValues.nameOverride) (ne $name (include "bjw-s.common.lib.route.primary" $)) -}}
|
||||
{{- $_ := set $routeValues "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue