Skip to content

Commit

Permalink
Make replicas optional for Deployment and StatefulSet (#12)
Browse files Browse the repository at this point in the history
Adding the ability to not include the `replicas` field on the Deployment/StatefulSet definition. Including it can cause issues in certain situations like when using HorizontalPodAutoscaler.
  • Loading branch information
arunanandhan authored Nov 10, 2022
1 parent 3afdc6a commit fd5bf8c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.replicasEnabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "spacelift-worker.selectorLabels" . | nindent 6 }}
Expand Down
2 changes: 2 additions & 0 deletions templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.replicasEnabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "spacelift-worker.selectorLabels" . | nindent 6 }}
Expand Down
2 changes: 2 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# replicas.enabled defines whether the `replicas` field is set against the Deployment or StatefulSet. This allows you to prevent the field from being set when using a HPA, as recommended in the Kubernetes documentation: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#migrating-deployments-and-statefulsets-to-horizontal-autoscaling.
replicasEnabled : true
# replicaCount defines the number of Spacelift workers that will be created.
replicaCount: 1
# terminationGracePeriodSeconds specifies how long Kubernetes gives a worker pod to gracefully
Expand Down

0 comments on commit fd5bf8c

Please sign in to comment.