-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pdb for sbx/dev/test envs + logic (#109)
* feat: add pdb for sbx/dev/test envs + logic * fix: pdb on replicas 1 --------- Co-authored-by: Alexander Brevig <[email protected]>
- Loading branch information
1 parent
320b80a
commit b4b246a
Showing
4 changed files
with
110 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
{{- /* Rules */}} | ||
{{- $env := .Values.env | required ".Values.common.env is required." -}} | ||
{{- $releaseName := include "name" . -}} | ||
{{- $minAvailable := .Values.deployment.minAvailable | default .Values.container.minAvailable }} | ||
{{- $forceReplicas := .Values.deployment.forceReplicas | default .Values.container.forceReplicas }} | ||
{{- $replicas := .Values.deployment.replicas | default .Values.container.replicas }} | ||
|
||
{{- if (and (not (eq (int $forceReplicas) 1)) (or (eq "prd" .Values.env) $minAvailable) )}} | ||
{{- if (and (ne "prd" .Values.env) (eq 1 (int $replicas))) }} | ||
{{ $checkReplicas := .Values.error | required ".Values.common.container.replicas must be greater than 1 when using minAvailable" }} | ||
{{- end }} | ||
|
||
{{- $releaseNamespace := .Release.Namespace -}} | ||
{{- $forceReplicas := .Values.deployment.forceReplicas | default .Values.container.forceReplicas -}} | ||
{{- $minAvailable := .Values.deployment.minAvailable | default .Values.container.minAvailable -}} | ||
{{- $minAvailablePDB := .Values.pdb.minAvailable -}} | ||
{{- $replicas := .Values.deployment.replicas | default .Values.container.replicas -}} | ||
{{- /* YAML Spec */}} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ $releaseName }} | ||
namespace: {{ .Release.Namespace }} | ||
namespace: {{ $releaseNamespace }} | ||
labels: | ||
{{- include "labels" . | indent 4 }} | ||
spec: | ||
{{- if ((.Values.pdb).minAvailable) }} | ||
minAvailable: {{ .Values.pdb.minAvailable }} | ||
{{- if (or (eq (int $replicas) 1) (eq (int $forceReplicas) 1)) }} | ||
{{- /* We set PDB even if forceReplicas or replicas = 1 */}} | ||
{{- /* This is because helm is not able to delete unknown-previous config. */}} | ||
{{- /* In this case we set the minAvailable to 0% so it behaves the same way as a PDB does not exist. */}} | ||
minAvailable: 0% | ||
{{- else if ($minAvailablePDB) }} | ||
{{- /* PDB.minAvailable takes precedence over deployment/container.minAvailable */}} | ||
minAvailable: {{ $minAvailablePDB }} | ||
{{- else }} | ||
minAvailable: {{ $minAvailable | default "50%" }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
app: {{ $releaseName }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters