diff --git a/charts/kyverno/Chart.yaml b/charts/kyverno/Chart.yaml index dfdc0fa7d6..edd8f6bbc6 100644 --- a/charts/kyverno/Chart.yaml +++ b/charts/kyverno/Chart.yaml @@ -28,3 +28,5 @@ annotations: artifacthub.io/changes: | - kind: added description: make sigstore volume configurable + - kind: changed + description: no deployments can run with 0 replicas diff --git a/charts/kyverno/templates/_helpers/_deployment.tpl b/charts/kyverno/templates/_helpers/_deployment.tpl new file mode 100644 index 0000000000..efc70081ee --- /dev/null +++ b/charts/kyverno/templates/_helpers/_deployment.tpl @@ -0,0 +1,8 @@ +{{/* vim: set filetype=mustache: */}} + +{{- define "kyverno.deployment.replicas" -}} + {{- if eq . 0 -}} + {{- fail "Kyverno does not support running with 0 replicas. Please provide a non-zero value." -}} + {{- end -}} + {{- . -}} +{{- end -}} \ No newline at end of file diff --git a/charts/kyverno/templates/admission-controller/deployment.yaml b/charts/kyverno/templates/admission-controller/deployment.yaml index df45c17922..c92b4b0cff 100644 --- a/charts/kyverno/templates/admission-controller/deployment.yaml +++ b/charts/kyverno/templates/admission-controller/deployment.yaml @@ -7,9 +7,7 @@ metadata: labels: {{- include "kyverno.admission-controller.labels" . | nindent 4 }} spec: - {{- with .Values.replicaCount }} - replicas: {{ . }} - {{- end }} + replicas: {{ template "kyverno.deployment.replicas" .Values.replicaCount }} selector: matchLabels: {{- include "kyverno.admission-controller.matchLabels" . | nindent 6 }} diff --git a/charts/kyverno/templates/background-controller/deployment.yaml b/charts/kyverno/templates/background-controller/deployment.yaml index cb896335d9..42bf932ab0 100644 --- a/charts/kyverno/templates/background-controller/deployment.yaml +++ b/charts/kyverno/templates/background-controller/deployment.yaml @@ -8,9 +8,7 @@ metadata: {{- include "kyverno.background-controller.labels" . | nindent 4 }} namespace: {{ template "kyverno.namespace" . }} spec: - {{- with .Values.backgroundController.replicas }} - replicas: {{ . }} - {{- end }} + replicas: {{ template "kyverno.deployment.replicas" .Values.backgroundController.replicas }} {{- with .Values.backgroundController.updateStrategy }} strategy: {{- toYaml . | nindent 4 }} diff --git a/charts/kyverno/templates/cleanup-controller/deployment.yaml b/charts/kyverno/templates/cleanup-controller/deployment.yaml index 982550e878..363b04948f 100644 --- a/charts/kyverno/templates/cleanup-controller/deployment.yaml +++ b/charts/kyverno/templates/cleanup-controller/deployment.yaml @@ -8,9 +8,7 @@ metadata: {{- include "kyverno.cleanup-controller.labels" . | nindent 4 }} namespace: {{ template "kyverno.namespace" . }} spec: - {{- with .Values.cleanupController.replicas }} - replicas: {{ . }} - {{- end }} + replicas: {{ template "kyverno.deployment.replicas" .Values.cleanupController.replicas }} {{- with .Values.cleanupController.updateStrategy }} strategy: {{- toYaml . | nindent 4 }} diff --git a/charts/kyverno/templates/reports-controller/deployment.yaml b/charts/kyverno/templates/reports-controller/deployment.yaml index 93d550851f..7466a99fda 100644 --- a/charts/kyverno/templates/reports-controller/deployment.yaml +++ b/charts/kyverno/templates/reports-controller/deployment.yaml @@ -8,9 +8,7 @@ metadata: {{- include "kyverno.reports-controller.labels" . | nindent 4 }} namespace: {{ template "kyverno.namespace" . }} spec: - {{- with .Values.reportsController.replicas }} - replicas: {{ . }} - {{- end }} + replicas: {{ template "kyverno.deployment.replicas" .Values.reportsController.replicas }} {{- with .Values.reportsController.updateStrategy }} strategy: {{- toYaml . | nindent 4 }}