Skip to content

Commit

Permalink
Allow 0 replicas which is helpful when debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Sep 12, 2024
1 parent 1140ae4 commit 1f8d3f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 9 additions & 0 deletions charts/helm-project-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ heritage: {{ $.Release.Service | quote }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end -}}

{{/* Replica Default - Allow setting to 0, or default to 1 */}}
{{- define "replicaDefault" -}}
{{- if (eq 0 (int .Values.replicas)) -}}
{{ .Values.replicas }}
{{- else -}}
{{ default .Values.replicas 1 }}
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions charts/helm-project-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ metadata:
labels: {{ include "helm-project-operator.labels" . | nindent 4 }}
app: {{ template "helm-project-operator.name" . }}
spec:
{{- if .Values.replicas }}
replicas: {{ .Values.replicas }}
{{- end }}
replicas: {{ include "replicaDefault" . }}
selector:
matchLabels:
app: {{ template "helm-project-operator.name" . }}
Expand Down

0 comments on commit 1f8d3f4

Please sign in to comment.