From 9359acede01b70ef340f7a6130565904cb518944 Mon Sep 17 00:00:00 2001 From: Dmytro Bondar Date: Fri, 17 Apr 2026 16:03:50 +0200 Subject: [PATCH] Add extra workload types --- charts/base/Chart.yaml | 2 +- charts/base/README.md | 10 ++++++-- charts/base/templates/daemonset.yaml | 20 ++++++++++++++++ charts/base/templates/deployment.yaml | 2 ++ charts/base/templates/pod.yaml | 12 ++++++++++ charts/base/templates/statefulset.yaml | 33 ++++++++++++++++++++++++++ charts/base/values.yaml | 20 +++++++++++++++- 7 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 charts/base/templates/daemonset.yaml create mode 100644 charts/base/templates/pod.yaml create mode 100644 charts/base/templates/statefulset.yaml diff --git a/charts/base/Chart.yaml b/charts/base/Chart.yaml index 71d3251..8e573cb 100644 --- a/charts/base/Chart.yaml +++ b/charts/base/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: base description: Base Helm chart for Kubernetes - fully values-driven. type: application -version: 0.1.1 +version: 0.2.0 maintainers: - name: bonddim sources: diff --git a/charts/base/README.md b/charts/base/README.md index dfaa8ed..7d64550 100644 --- a/charts/base/README.md +++ b/charts/base/README.md @@ -1,6 +1,6 @@ # base -![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) +![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) Base Helm chart for Kubernetes - fully values-driven. @@ -36,10 +36,16 @@ Base Helm chart for Kubernetes - fully values-driven. | Key | Type | Default | Description | |-----|------|---------|-------------| -| annotations | object | `{}` | Additional annotations on the Deployment resource itself. | +| workload | string | `"deployment"` | Workload type to deploy. One of: deployment, daemonset, statefulset, pod or null | +| annotations | object | `{}` | Additional annotations on the Workload resource itself. | | labels | object | `{}` | Additional labels on the Deployment resource itself. | | replicas | int | `nil` | Number of pod replicas. Ignored when autoscaling.enabled=true. Must be >= 0 if specified. null by default, which defaults to 1 and not controlled by Helm. | | strategy | object | `{}` | Deployment update strategy. e.g. { type: RollingUpdate, rollingUpdate: { maxSurge: 1, maxUnavailable: 0 } } | +| updateStrategy | object | `{}` | DaemonSet/StatefulSet update strategy. e.g. { type: RollingUpdate } or { type: OnDelete } | +| serviceName | string | `""` | StatefulSet service name. Defaults to the fullname when empty. | +| podManagementPolicy | string | `""` | StatefulSet pod management policy: OrderedReady or Parallel. | +| volumeClaimTemplates | list | `[]` | StatefulSet volumeClaimTemplates for persistent storage. | +| persistentVolumeClaimRetentionPolicy | object | `{}` | StatefulSet persistentVolumeClaimRetentionPolicy. | | revisionHistoryLimit | int | `nil` | Number of old ReplicaSets to retain. | | podAnnotations | object | `{}` | Additional annotations on the Pod template. | | podLabels | object | `{}` | Additional labels on the Pod template. | diff --git a/charts/base/templates/daemonset.yaml b/charts/base/templates/daemonset.yaml new file mode 100644 index 0000000..cec6381 --- /dev/null +++ b/charts/base/templates/daemonset.yaml @@ -0,0 +1,20 @@ +{{- if eq .Values.workload "daemonset" -}} +apiVersion: apps/v1 +kind: DaemonSet +metadata: + {{- with include "base.annotations" (dict "annotations" .Values.annotations "context" .) }} + annotations: {{- . | nindent 4 }} + {{- end }} + labels: {{- include "base.labels" (dict "labels" .Values.labels "context" .) | nindent 4 }} + name: {{ include "base.fullname" . }} +spec: + {{- with .Values.revisionHistoryLimit }} + revisionHistoryLimit: {{ . }} + {{- end }} + selector: + matchLabels: {{- include "base.selectorLabels" . | nindent 6 }} + {{- with .Values.updateStrategy }} + updateStrategy: {{- toYaml . | nindent 4 }} + {{- end }} + template: {{- include "base.podTemplate" . | nindent 4 }} +{{- end }} diff --git a/charts/base/templates/deployment.yaml b/charts/base/templates/deployment.yaml index 478839d..8633a1d 100644 --- a/charts/base/templates/deployment.yaml +++ b/charts/base/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.workload "deployment" -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -19,3 +20,4 @@ spec: strategy: {{- toYaml . | nindent 4 }} {{- end }} template: {{- include "base.podTemplate" . | nindent 4 }} +{{- end }} diff --git a/charts/base/templates/pod.yaml b/charts/base/templates/pod.yaml new file mode 100644 index 0000000..3ad5e75 --- /dev/null +++ b/charts/base/templates/pod.yaml @@ -0,0 +1,12 @@ +{{- if eq .Values.workload "pod" -}} +{{- $podTemplate := include "base.podTemplate" . | fromYaml -}} +apiVersion: v1 +kind: Pod +metadata: + {{- with $podTemplate.metadata.annotations }} + annotations: {{- . | nindent 4 }} + {{- end }} + labels: {{- $podTemplate.metadata.labels | toYaml | nindent 4 }} + name: {{ include "base.fullname" . }} +spec: {{- $podTemplate.spec | toYaml | nindent 2 }} +{{- end }} diff --git a/charts/base/templates/statefulset.yaml b/charts/base/templates/statefulset.yaml new file mode 100644 index 0000000..117ba47 --- /dev/null +++ b/charts/base/templates/statefulset.yaml @@ -0,0 +1,33 @@ +{{- if eq .Values.workload "statefulset" -}} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + {{- with include "base.annotations" (dict "annotations" .Values.annotations "context" .) }} + annotations: {{- . | nindent 4 }} + {{- end }} + labels: {{- include "base.labels" (dict "labels" .Values.labels "context" .) | nindent 4 }} + name: {{ include "base.fullname" . }} +spec: + {{- if and (not .Values.autoscaling.enabled) (ge (int .Values.replicas) 0) }} + replicas: {{ .Values.replicas }} + {{- end }} + {{- with .Values.revisionHistoryLimit }} + revisionHistoryLimit: {{ . }} + {{- end }} + selector: + matchLabels: {{- include "base.selectorLabels" . | nindent 6 }} + serviceName: {{ default (include "base.fullname" .) .Values.serviceName }} + {{- with .Values.podManagementPolicy }} + podManagementPolicy: {{ . }} + {{- end }} + {{- with .Values.updateStrategy }} + updateStrategy: {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.persistentVolumeClaimRetentionPolicy }} + persistentVolumeClaimRetentionPolicy: {{- toYaml . | nindent 4 }} + {{- end }} + template: {{- include "base.podTemplate" . | nindent 4 }} + {{- with .Values.volumeClaimTemplates }} + volumeClaimTemplates: {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/base/values.yaml b/charts/base/values.yaml index 7fb55db..159edc2 100644 --- a/charts/base/values.yaml +++ b/charts/base/values.yaml @@ -32,7 +32,10 @@ commonAnnotations: {} ######################################################################## ### Workload ### ######################################################################## -# -- Additional annotations on the Deployment resource itself. +# -- Workload type to deploy. One of: deployment, daemonset, statefulset, pod or null +# @section -- Workload parameters +workload: deployment +# -- Additional annotations on the Workload resource itself. # @section -- Workload parameters annotations: {} # -- Additional labels on the Deployment resource itself. @@ -45,6 +48,21 @@ replicas: null # -- Deployment update strategy. e.g. { type: RollingUpdate, rollingUpdate: { maxSurge: 1, maxUnavailable: 0 } } # @section -- Workload parameters strategy: {} +# -- DaemonSet/StatefulSet update strategy. e.g. { type: RollingUpdate } or { type: OnDelete } +# @section -- Workload parameters +updateStrategy: {} +# -- (string) StatefulSet service name. Defaults to the fullname when empty. +# @section -- Workload parameters +serviceName: "" +# -- (string) StatefulSet pod management policy: OrderedReady or Parallel. +# @section -- Workload parameters +podManagementPolicy: "" +# -- StatefulSet volumeClaimTemplates for persistent storage. +# @section -- Workload parameters +volumeClaimTemplates: [] +# -- StatefulSet persistentVolumeClaimRetentionPolicy. +# @section -- Workload parameters +persistentVolumeClaimRetentionPolicy: {} # -- (int) Number of old ReplicaSets to retain. # @section -- Workload parameters revisionHistoryLimit: null