diff --git a/library/common-test/Chart.yaml b/library/common-test/Chart.yaml index fd5cfbb8..d9bd3ff1 100644 --- a/library/common-test/Chart.yaml +++ b/library/common-test/Chart.yaml @@ -3,7 +3,7 @@ appVersion: "" dependencies: - name: common repository: file://../common - version: ~12.7.0 + version: ~12.8.0 deprecated: false description: Helper chart to test different use cases of the common library home: https://github.com/truecharts/apps/tree/master/charts/library/common-test diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 7eeec931..8ad42dbb 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.7.1 +version: 12.8.0 diff --git a/library/common/templates/class/_cnpgCluster.tpl b/library/common/templates/class/_cnpgCluster.tpl index e309e657..13cd31d3 100644 --- a/library/common/templates/class/_cnpgCluster.tpl +++ b/library/common/templates/class/_cnpgCluster.tpl @@ -23,7 +23,7 @@ metadata: {{- end }} {{- $annotations := (mustMerge ($cnpgClusterAnnotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $ | fromYaml)) }} annotations: - cnpg.io/hibernation: {{ if $values.hibernate }}"on"{{ else }}"off"{{ end }} + cnpg.io/hibernation: {{ if or $values.hibernate $.Values.global.stopAll }}"on"{{ else }}"off"{{ end }} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $ "annotations" $annotations) | trim) }} {{- . | nindent 4 }} {{- end }} diff --git a/library/common/templates/class/_cnpgPooler.tpl b/library/common/templates/class/_cnpgPooler.tpl index 67b63a5a..fb1850d1 100644 --- a/library/common/templates/class/_cnpgPooler.tpl +++ b/library/common/templates/class/_cnpgPooler.tpl @@ -21,7 +21,7 @@ spec: cluster: name: {{ $cnpgClusterName }} - instances: {{ if $values.hibernate}}0{{ else }}{{ $values.pooler.instances | default 2 }}{{ end }} + instances: {{ if or $values.hibernate $.Values.global.stopAll }}0{{ else }}{{ $values.pooler.instances | default 2 }}{{ end }} type: {{ $values.pooler.type }} pgbouncer: poolMode: session diff --git a/library/common/templates/lib/pod/_nodeSelector.tpl b/library/common/templates/lib/pod/_nodeSelector.tpl index c3bdbaf4..b69be715 100644 --- a/library/common/templates/lib/pod/_nodeSelector.tpl +++ b/library/common/templates/lib/pod/_nodeSelector.tpl @@ -20,10 +20,14 @@ objectData: The object data to be used to render the Pod. {{- $selectors = . -}} {{- end -}} - {{- range $k, $v := $selectors -}} - {{- if not $v -}} - {{- fail (printf "Expected non-empty value on [%s] key." $k) -}} - {{- end }} + {{- if and $rootCtx.Values.global.stopAll ( eq $objectData.type "DaemonSet" ) -}} +"non-existing": "true" + {{- else -}} + {{- range $k, $v := $selectors -}} + {{- if not $v -}} + {{- fail (printf "Expected non-empty value on [%s] key." $k) -}} + {{- end }} {{ $k }}: {{ tpl $v $rootCtx }} + {{- end -}} {{- end -}} {{- end -}} diff --git a/library/common/templates/lib/workload/_cronjobSpec.tpl b/library/common/templates/lib/workload/_cronjobSpec.tpl index bae128e9..1742328e 100644 --- a/library/common/templates/lib/workload/_cronjobSpec.tpl +++ b/library/common/templates/lib/workload/_cronjobSpec.tpl @@ -20,6 +20,7 @@ concurrencyPolicy: {{ $objectData.concurrencyPolicy | default "Forbid" }} failedJobsHistoryLimit: {{ $objectData.failedJobsHistoryLimit | default 1 }} successfulJobsHistoryLimit: {{ $objectData.successfulJobsHistoryLimit | default 3 }} startingDeadlineSeconds: {{ $objectData.startingDeadlineSeconds | default 600 }} +suspend: {{ if $rootCtx.Values.global.stopAll }}true {{ else }}{{ $objectData.suspend | default false }}{{ end }} jobTemplate: spec: {{- include "tc.v1.common.lib.workload.jobSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | indent 4 }} diff --git a/library/common/templates/lib/workload/_deployementSpec.tpl b/library/common/templates/lib/workload/_deployementSpec.tpl index 3d794903..3682df8a 100644 --- a/library/common/templates/lib/workload/_deployementSpec.tpl +++ b/library/common/templates/lib/workload/_deployementSpec.tpl @@ -11,7 +11,7 @@ objectData: {{- $objectData := .objectData -}} {{- $rootCtx := .rootCtx -}} {{- $strategy := $objectData.strategy | default "Recreate" }} -replicas: {{ $objectData.replicas | default 1 }} +replicas: {{ if $rootCtx.Values.global.stopAll }}0{{ else }}{{ $objectData.replicas | default 1 }}{{ end }} revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }} strategy: type: {{ $strategy }} diff --git a/library/common/templates/lib/workload/_jobSpec.tpl b/library/common/templates/lib/workload/_jobSpec.tpl index 8eb5e89f..3ae403ad 100644 --- a/library/common/templates/lib/workload/_jobSpec.tpl +++ b/library/common/templates/lib/workload/_jobSpec.tpl @@ -16,7 +16,7 @@ objectData: backoffLimit: {{ $objectData.backoffLimit | default 5 }} completionMode: {{ $objectData.completionMode | default "NonIndexed" }} completions: {{ $objectData.completions | default nil }} -parallelism: {{ $objectData.parallelism | default 1 }} +parallelism: {{ if $rootCtx.Values.global.stopAll }}0{{ else }}{{ $objectData.parallelism | default 1 }}{{ end }} ttlSecondsAfterFinished: {{ $objectData.ttlSecondsAfterFinished | default 120 }} {{- with $objectData.activeDeadlineSeconds }} activeDeadlineSeconds: {{ . }} diff --git a/library/common/templates/lib/workload/_statefulsettSpec.tpl b/library/common/templates/lib/workload/_statefulsettSpec.tpl index 539d087b..0a9047e3 100644 --- a/library/common/templates/lib/workload/_statefulsettSpec.tpl +++ b/library/common/templates/lib/workload/_statefulsettSpec.tpl @@ -11,7 +11,7 @@ objectData: {{- $objectData := .objectData -}} {{- $rootCtx := .rootCtx -}} {{- $strategy := $objectData.strategy | default "RollingUpdate" }} -replicas: {{ $objectData.replicas | default 1 }} +replicas: {{ if $rootCtx.Values.global.stopAll }}0{{ else }}{{ $objectData.replicas | default 1 }}{{ end }} revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }} serviceName: {{ $objectData.name }} updateStrategy: diff --git a/library/common/values.yaml b/library/common/values.yaml index 98c2f4b2..26435664 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -10,6 +10,9 @@ global: addTraefikAnnotations: true # -- Minimum nodePort value minNodePort: 9000 + # -- Enable to stop most pods and containers including cnpg + # does not include stand-alone pods + stopAll: false fallbackDefaults: # -- Define a storageClassName that will be used for all PVCs