From 5dc5eeb4bcfbdd884f11952feef3bc208c56cfe6 Mon Sep 17 00:00:00 2001 From: Taehyun Kim Date: Wed, 12 Jun 2024 16:20:23 +0900 Subject: [PATCH 1/3] feat: add pdb --- helm/templates/pdb.yaml | 25 +++++++++++++++++++++++++ helm/values.yaml | 7 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 helm/templates/pdb.yaml diff --git a/helm/templates/pdb.yaml b/helm/templates/pdb.yaml new file mode 100644 index 00000000..8f784593 --- /dev/null +++ b/helm/templates/pdb.yaml @@ -0,0 +1,25 @@ +{{- if .Values.pdb.enabled -}} +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: {{ include "app.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "app.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + k8s-app: {{ include "app.name" . }} + helm.sh/chart: {{ include "chart.name-version" . }} + control-plane: controller +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ include "app.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{- with .Values.pdb.minAvailable }} + minAvailable: {{ . }} + {{- end }} + {{- with .Values.pdb.maxUnavailable }} + maxUnavailable: {{ . }} + {{- end }} +{{- end -}} diff --git a/helm/values.yaml b/helm/values.yaml index 2fcc4414..9382b549 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -35,7 +35,7 @@ deployment: # If "installScope: cluster" then these labels will be applied to ClusterRole role: - labels: {} + labels: {} metrics: service: @@ -54,6 +54,11 @@ resources: memory: "128Mi" cpu: "100m" +pdb: + enabled: false + minAvailable: + maxUnavailable: + # log level for the controller log: level: info From fd9a3f89fb8ca7dde459bca19497591182bd9763 Mon Sep 17 00:00:00 2001 From: Taehyun Kim Date: Thu, 13 Jun 2024 14:15:05 +0900 Subject: [PATCH 2/3] topologySpreadConstraints --- helm/templates/deployment.yaml | 5 ++++- helm/templates/pdb.yaml | 2 +- helm/values.yaml | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 6687e504..fe96e2a0 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -110,4 +110,7 @@ spec: {{ end -}} {{ if .Values.deployment.priorityClassName -}} priorityClassName: {{ .Values.deployment.priorityClassName }} - {{ end -}} \ No newline at end of file + {{ end -}} + {{ if .Values.deployment.topologySpreadConstraints -}} + topologySpreadConstraints: {{ .Values.deployment.topologySpreadConstraints | toYaml | nindent 8 }} + {{ end -}} diff --git a/helm/templates/pdb.yaml b/helm/templates/pdb.yaml index 8f784593..31c4e292 100644 --- a/helm/templates/pdb.yaml +++ b/helm/templates/pdb.yaml @@ -1,5 +1,5 @@ {{- if .Values.pdb.enabled -}} -apiVersion: policy/v1beta1 +apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ include "app.fullname" . }} diff --git a/helm/values.yaml b/helm/values.yaml index 9382b549..13d76c1d 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -32,6 +32,7 @@ deployment: priorityClassName: "" # Number of replicas. replicas: 2 + topologySpreadConstraints: [] # If "installScope: cluster" then these labels will be applied to ClusterRole role: From 01462bf7e52ab2317e42b7c18da26bf98fcfe2bb Mon Sep 17 00:00:00 2001 From: Taehyun Kim Date: Fri, 20 Sep 2024 16:10:02 +0900 Subject: [PATCH 3/3] add namespace to pdb --- helm/templates/pdb.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm/templates/pdb.yaml b/helm/templates/pdb.yaml index 31c4e292..f0a54f56 100644 --- a/helm/templates/pdb.yaml +++ b/helm/templates/pdb.yaml @@ -3,6 +3,7 @@ apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ include "app.fullname" . }} + namespace: {{ .Release.Namespace }} labels: app.kubernetes.io/name: {{ include "app.name" . }} app.kubernetes.io/instance: {{ .Release.Name }}