From 903f7d678039723cddc5b36ede3cfb9e382d7a69 Mon Sep 17 00:00:00 2001 From: Bernd Schorgers Date: Wed, 14 Feb 2024 13:30:12 +0100 Subject: [PATCH] feat(common): Release v2.6.0 (#268) --- .github/workflows/charts-test.yaml | 10 +++++----- .../tests/configmap/pod_metadata_test.yaml | 9 ++++++++- .../tests/controller/cronjob_test.yaml | 5 +++++ .../common-test/tests/controller/job_test.yaml | 5 +++++ .../tests/secret/pod_metadata_test.yaml | 7 +++++-- charts/library/common/Chart.yaml | 18 +++--------------- charts/library/common/README.md | 10 +++++++--- .../common/templates/classes/_cronjob.tpl | 3 +++ .../library/common/templates/classes/_job.tpl | 9 +++++++++ .../lib/pod/metadata/_annotations.tpl | 12 ++++++++++-- charts/library/common/values.yaml | 8 ++++++++ 11 files changed, 68 insertions(+), 28 deletions(-) diff --git a/.github/workflows/charts-test.yaml b/.github/workflows/charts-test.yaml index c7f0444b..056bc7cd 100644 --- a/.github/workflows/charts-test.yaml +++ b/.github/workflows/charts-test.yaml @@ -31,13 +31,13 @@ jobs: chart: ${{ fromJSON(inputs.chartsToTest) }} k8s_version: [ - "v1.22.17", "v1.23.17", "v1.24.17", - "v1.25.13", - "v1.26.8", - "v1.27.5", - "v1.28.1", + "v1.25.16", + "v1.26.13", + "v1.27.10", + "v1.28.6", + "v1.29.1", ] fail-fast: false steps: diff --git a/charts/library/common-test/tests/configmap/pod_metadata_test.yaml b/charts/library/common-test/tests/configmap/pod_metadata_test.yaml index 4d1f9952..cb89dcd9 100644 --- a/charts/library/common-test/tests/configmap/pod_metadata_test.yaml +++ b/charts/library/common-test/tests/configmap/pod_metadata_test.yaml @@ -11,6 +11,13 @@ tests: enabled: true data: test: value 1 + test_default_enabled: + data: + test: value 1 + test_disabled: + enabled: false + data: + test: value 1 asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -19,4 +26,4 @@ tests: equal: path: spec.template.metadata.annotations value: - checksum/configMaps: afdf20f511621d5cb358c5e8b0da2d14cdbe2549fb12fa123f6a6e9baabef26e + checksum/configMaps: 66d23d7a53c4e2a523ba85a969696b4ebb78ec5d79ab9c12c210c1569f48511b diff --git a/charts/library/common-test/tests/controller/cronjob_test.yaml b/charts/library/common-test/tests/controller/cronjob_test.yaml index 663294d2..d96b8d48 100644 --- a/charts/library/common-test/tests/controller/cronjob_test.yaml +++ b/charts/library/common-test/tests/controller/cronjob_test.yaml @@ -54,6 +54,7 @@ tests: failedJobsHistory: &CronJobFailedJobsHistory 2 successfulJobsHistory: &CronJobSuccessfulJobsHistory 3 ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600 + parallelism: &CronJobParallelism 3 asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -86,3 +87,7 @@ tests: equal: path: spec.jobTemplate.spec.template.spec.restartPolicy value: OnFailure + - documentIndex: *ControllerDoc + equal: + path: spec.jobTemplate.spec.parallelism + value: *CronJobParallelism diff --git a/charts/library/common-test/tests/controller/job_test.yaml b/charts/library/common-test/tests/controller/job_test.yaml index 4de92a35..4298bdcd 100644 --- a/charts/library/common-test/tests/controller/job_test.yaml +++ b/charts/library/common-test/tests/controller/job_test.yaml @@ -35,6 +35,7 @@ tests: suspend: &JobSuspended true ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600 backoffLimit: 3 + parallelism: &JobParallelism 3 asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -55,3 +56,7 @@ tests: equal: path: spec.backoffLimit value: 3 + - documentIndex: *ControllerDoc + equal: + path: spec.parallelism + value: *JobParallelism diff --git a/charts/library/common-test/tests/secret/pod_metadata_test.yaml b/charts/library/common-test/tests/secret/pod_metadata_test.yaml index 0b52e233..117d9fc8 100644 --- a/charts/library/common-test/tests/secret/pod_metadata_test.yaml +++ b/charts/library/common-test/tests/secret/pod_metadata_test.yaml @@ -11,11 +11,14 @@ tests: enabled: true data: test: value 1 - secret_2: - enabled: true + secret_2: # default enabled data: test_1: value 1 test_2: value 2 + test_disabled: + enabled: false + data: + test: value 1 asserts: - documentIndex: &ControllerDoc 0 isKind: diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 7226186b..98c948ba 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 name: common description: Function library for Helm charts type: library -version: 2.5.0 +version: 2.6.0 kubeVersion: ">=1.22.0-0" keywords: - common @@ -16,19 +16,7 @@ annotations: artifacthub.io/changes: |- - kind: fixed description: |- - PersistentVolumeClaims now properly created based on `persistence.x.enabled` value + ConfigMap and Secret checksums take enabled state in to account again - kind: added description: |- - Support suspending CronJobs - - kind: added - description: |- - Add support for targetLabels in ServiceMonitor - - kind: added - description: |- - Re-add support for setting mountPropagation on volumemounts - - kind: added - description: |- - Support `envFrom` identifiers and name templates for Secrets and ConfigMaps - - kind: added - description: |- - Support the `job` controller type to generate one-off jobs. + Add support for specifying parallelism in CronJobs and Jobs diff --git a/charts/library/common/README.md b/charts/library/common/README.md index 76cef450..fa0a3973 100644 --- a/charts/library/common/README.md +++ b/charts/library/common/README.md @@ -1,6 +1,6 @@ # common -![Version: 2.5.0](https://img.shields.io/badge/Version-2.5.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) +![Version: 2.6.0](https://img.shields.io/badge/Version-2.6.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) Function library for Helm charts @@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g. # Chart.yaml dependencies: - name: common - version: 2.5.0 + version: 2.6.0 repository: https://bjw-s.github.io/helm-charts/ ``` @@ -90,6 +90,7 @@ The following table contains an overview of available values and their descripti | controllers.main.cronjob.backoffLimit | int | `6` | Limits the number of times a failed job will be retried | | controllers.main.cronjob.concurrencyPolicy | string | `"Forbid"` | Specifies how to treat concurrent executions of a job that is created by this cron job valid values are Allow, Forbid or Replace | | controllers.main.cronjob.failedJobsHistory | int | `1` | The number of failed Jobs to keep | +| controllers.main.cronjob.parallelism | string | `nil` | Specify the number of parallel jobs | | controllers.main.cronjob.schedule | string | `"*/20 * * * *"` | Sets the CronJob time when to execute your jobs | | controllers.main.cronjob.startingDeadlineSeconds | int | `30` | The deadline in seconds for starting the job if it misses its scheduled time for any reason | | controllers.main.cronjob.successfulJobsHistory | int | `1` | The number of succesful Jobs to keep | @@ -100,6 +101,9 @@ The following table contains an overview of available values and their descripti | controllers.main.initContainers | object | `{}` | Specify any initContainers here as dictionary items. Each initContainer should have its own key initContainers get sorted alphanumerically by the `-` combination if no order or dependsOn has been configured for them. | | controllers.main.job | object | See below | Job configuration. Required only when using `controller.type: job`. | | controllers.main.job.backoffLimit | int | `6` | Limits the number of times a failed job will be retried | +| controllers.main.job.completionMode | string | `nil` | Specify the completionMode for the job | +| controllers.main.job.completions | string | `nil` | Specify the number of completions for the job | +| controllers.main.job.parallelism | string | `nil` | Specify the number of parallel jobs | | controllers.main.job.suspend | string | false | Suspends the Job [[ref]](https://kubernetes.io/docs/concepts/workloads/controllers/job/#suspending-a-job) | | controllers.main.job.ttlSecondsAfterFinished | string | `nil` | If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. | | controllers.main.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset/cronjob/job | @@ -231,4 +235,4 @@ The following table contains an overview of available values and their descripti - Join the k8s-at-home [Discord](https://discord.gg/k8s-at-home) community ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3) +Autogenerated from chart metadata using [helm-docs v1.12.0](https://github.com/norwoodj/helm-docs/releases/v1.12.0) diff --git a/charts/library/common/templates/classes/_cronjob.tpl b/charts/library/common/templates/classes/_cronjob.tpl index 829f54fc..84657d95 100644 --- a/charts/library/common/templates/classes/_cronjob.tpl +++ b/charts/library/common/templates/classes/_cronjob.tpl @@ -48,6 +48,9 @@ spec: {{- with $cronjobObject.cronjob.ttlSecondsAfterFinished }} ttlSecondsAfterFinished: {{ . }} {{- end }} + {{- with $cronjobObject.cronjob.parallelism }} + parallelism: {{ . }} + {{- end }} backoffLimit: {{ $cronjobObject.cronjob.backoffLimit }} template: metadata: diff --git a/charts/library/common/templates/classes/_job.tpl b/charts/library/common/templates/classes/_job.tpl index 9c8a99ec..92ebb555 100644 --- a/charts/library/common/templates/classes/_job.tpl +++ b/charts/library/common/templates/classes/_job.tpl @@ -33,6 +33,15 @@ spec: {{- with $jobObject.job.ttlSecondsAfterFinished }} ttlSecondsAfterFinished: {{ . }} {{- end }} + {{- with $jobObject.job.parallelism }} + parallelism: {{ . }} + {{- end }} + {{- with $jobObject.job.completions }} + completions: {{ . }} + {{- end }} + {{- with $jobObject.job.completionMode }} + completionMode: {{ . }} + {{- end }} backoffLimit: {{ $jobObject.job.backoffLimit }} template: metadata: diff --git a/charts/library/common/templates/lib/pod/metadata/_annotations.tpl b/charts/library/common/templates/lib/pod/metadata/_annotations.tpl index 86e6d25f..9f203754 100644 --- a/charts/library/common/templates/lib/pod/metadata/_annotations.tpl +++ b/charts/library/common/templates/lib/pod/metadata/_annotations.tpl @@ -25,7 +25,11 @@ Returns the value for annotations {{- /* Add configMaps checksum */ -}} {{- $configMapsFound := dict -}} {{- range $name, $configmap := $rootContext.Values.configMaps -}} - {{- if $configmap.enabled -}} + {{- $configMapEnabled := true -}} + {{- if hasKey $configmap "enabled" -}} + {{- $configMapEnabled = $configmap.enabled -}} + {{- end -}} + {{- if $configMapEnabled -}} {{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}} {{- end -}} {{- end -}} @@ -39,7 +43,11 @@ Returns the value for annotations {{- /* Add Secrets checksum */ -}} {{- $secretsFound := dict -}} {{- range $name, $secret := $rootContext.Values.secrets -}} - {{- if $secret.enabled -}} + {{- $secretEnabled := true -}} + {{- if hasKey $secret "enabled" -}} + {{- $secretEnabled = $secret.enabled -}} + {{- end -}} + {{- if $secretEnabled -}} {{- $_ := set $secretsFound $name (toYaml $secret.stringData | sha256sum) -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 30b1bd13..506b3ef5 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -154,6 +154,8 @@ controllers: ttlSecondsAfterFinished: # -- Limits the number of times a failed job will be retried backoffLimit: 6 + # -- Specify the number of parallel jobs + parallelism: # -- Job configuration. Required only when using `controller.type: job`. # @default -- See below @@ -167,6 +169,12 @@ controllers: ttlSecondsAfterFinished: # -- Limits the number of times a failed job will be retried backoffLimit: 6 + # -- Specify the number of parallel jobs + parallelism: + # -- Specify the number of completions for the job + completions: + # -- Specify the completionMode for the job + completionMode: # -- StatefulSet configuration. Required only when using `controller.type: statefulset`. statefulset: