From 371652f49aeda6b0ad12380a467cbb2270a5436e Mon Sep 17 00:00:00 2001 From: chris onare Date: Fri, 30 May 2025 16:47:45 +1000 Subject: [PATCH 1/3] DEVOPS-2855 - Adding pod disruption budgets for frontend and worker deployments --- charts/argocd-apps/Values.yaml | 10 ++++++++++ charts/argocd-apps/templates/frontend-pdb.yaml | 16 ++++++++++++++++ charts/argocd-apps/templates/worker-pdb.yaml | 16 ++++++++++++++++ charts/generic-service/Values.yaml | 10 ++++++++++ .../generic-service/templates/frontend-pdb.yaml | 17 +++++++++++++++++ .../generic-service/templates/worker-pdb.yaml | 17 +++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 charts/argocd-apps/templates/frontend-pdb.yaml create mode 100644 charts/argocd-apps/templates/worker-pdb.yaml create mode 100644 charts/generic-service/templates/frontend-pdb.yaml create mode 100644 charts/generic-service/templates/worker-pdb.yaml diff --git a/charts/argocd-apps/Values.yaml b/charts/argocd-apps/Values.yaml index 7af3c09..5f09b72 100644 --- a/charts/argocd-apps/Values.yaml +++ b/charts/argocd-apps/Values.yaml @@ -16,6 +16,11 @@ main: name: targetGroupARN: securityGroupID: + pdb: + # Set to false to disable creating the PDB for frontend + enabled: true + # Minimum number of frontend pods that must be available during disruptions + minAvailable: 1 worker: name: enabled: @@ -27,3 +32,8 @@ worker: pullPolicy: resources: replicaCount: + pdb: + # Set to false to disable creating the PDB for frontend + enabled: true + # Minimum number of frontend pods that must be available during disruptions + minAvailable: 1 diff --git a/charts/argocd-apps/templates/frontend-pdb.yaml b/charts/argocd-apps/templates/frontend-pdb.yaml new file mode 100644 index 0000000..23c5415 --- /dev/null +++ b/charts/argocd-apps/templates/frontend-pdb.yaml @@ -0,0 +1,16 @@ +{{- if and .Values.main.enabled .Values.main.pdb.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ .Values.main.name }}-frontend-pdb + namespace: {{ $.Release.Namespace | quote }} + labels: + app: {{ .Values.main.name | quote }} +spec: + minAvailable: {{ .Values.main.pdb.minAvailable }} + selector: + matchLabels: + app.kubernetes.io/name: {{ .Values.main.name | quote }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} +{{- end }} diff --git a/charts/argocd-apps/templates/worker-pdb.yaml b/charts/argocd-apps/templates/worker-pdb.yaml new file mode 100644 index 0000000..f3dad3b --- /dev/null +++ b/charts/argocd-apps/templates/worker-pdb.yaml @@ -0,0 +1,16 @@ +{{- if and .Values.worker.enabled .Values.worker.pdb.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ .Values.worker.name }}-worker-pdb + namespace: {{ $.Release.Namespace | quote }} + labels: + app: {{ .Values.worker.name | quote }} +spec: + minAvailable: {{ .Values.worker.pdb.minAvailable }} + selector: + matchLabels: + app.kubernetes.io/name: {{ .Values.worker.name | quote }} + app.kubernetes.io/component: worker + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} +{{- end }} diff --git a/charts/generic-service/Values.yaml b/charts/generic-service/Values.yaml index 2adc7a1..6ba8ac6 100644 --- a/charts/generic-service/Values.yaml +++ b/charts/generic-service/Values.yaml @@ -23,6 +23,11 @@ frontend: secretRef: php-app-tls # pragma: allowlist secret imagepolicy: pattern: ^DEVOPS-338-deploy-breeze-qa-api-[a-fA-F0-9]+-(?P.*) + pdb: + # Set to false to disable creating the PDB for frontend + enabled: true + # Minimum number of frontend pods that must be available during disruptions + minAvailable: 1 worker: - name: worker @@ -35,6 +40,11 @@ worker: replicaCount: 1 imagepolicy: pattern: ^DEVOPS-338-deploy-breeze-qa-api-[a-fA-F0-9]+-(?P.*) + pdb: + # Set to false to disable creating the PDB for frontend + enabled: true + # Minimum number of frontend pods that must be available during disruptions + minAvailable: 1 autoscaling: enabled: true diff --git a/charts/generic-service/templates/frontend-pdb.yaml b/charts/generic-service/templates/frontend-pdb.yaml new file mode 100644 index 0000000..17bdd28 --- /dev/null +++ b/charts/generic-service/templates/frontend-pdb.yaml @@ -0,0 +1,17 @@ +{{- range $key, $value := .Values.frontend }} + {{- if and $value.pdb.enabled $value.name }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ $value.name }}-frontend-pdb + namespace: {{ $.Release.Namespace | quote }} + labels: + app: {{ $value.name | quote }} +spec: + minAvailable: {{ .Values.frontend.pdb.minAvailable }} + selector: + matchLabels: + app.kubernetes.io/name: {{ $value.name | quote }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} +{{- end }} diff --git a/charts/generic-service/templates/worker-pdb.yaml b/charts/generic-service/templates/worker-pdb.yaml new file mode 100644 index 0000000..31c9730 --- /dev/null +++ b/charts/generic-service/templates/worker-pdb.yaml @@ -0,0 +1,17 @@ +{{- range $key, $value := .Values.worker }} + {{- if and $value.pdb.enabled $value.name }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ $value.name }}-worker-pdb + namespace: {{ $.Release.Namespace | quote }} + labels: + app: {{ $value.name | quote }} +spec: + minAvailable: {{ .Values.worker.pdb.minAvailable }} + selector: + matchLabels: + app.kubernetes.io/name: {{ $value.name | quote }} + app.kubernetes.io/component: worker + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} +{{- end }} From d56b5e73e04dd4cecfcb9c8e38e093b29367bdc0 Mon Sep 17 00:00:00 2001 From: chris onare Date: Tue, 17 Jun 2025 16:10:35 +1000 Subject: [PATCH 2/3] DEVOPS-2855 - Set pod disruption budget to be enabled only if replicacount is more than 1 --- charts/argocd-apps/Chart.yaml | 2 +- charts/argocd-apps/Values.yaml | 8 ++------ charts/argocd-apps/templates/frontend-pdb.yaml | 16 +++++++++------- charts/argocd-apps/templates/worker-pdb.yaml | 16 +++++++++------- charts/generic-service/Chart.yaml | 2 +- charts/generic-service/Values.yaml | 10 +++------- .../generic-service/templates/frontend-pdb.yaml | 16 +++++++++------- charts/generic-service/templates/worker-pdb.yaml | 16 +++++++++------- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/charts/argocd-apps/Chart.yaml b/charts/argocd-apps/Chart.yaml index ace2555..7e6cf6d 100644 --- a/charts/argocd-apps/Chart.yaml +++ b/charts/argocd-apps/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v2 name: argocd-app description: A Helm chart for applications using ArgoCD -version: 0.9.1 +version: 0.9.2 diff --git a/charts/argocd-apps/Values.yaml b/charts/argocd-apps/Values.yaml index 5f09b72..0bf2ae9 100644 --- a/charts/argocd-apps/Values.yaml +++ b/charts/argocd-apps/Values.yaml @@ -17,9 +17,7 @@ main: targetGroupARN: securityGroupID: pdb: - # Set to false to disable creating the PDB for frontend - enabled: true - # Minimum number of frontend pods that must be available during disruptions + # (Optional) Minimum number of frontend pods that must be available during disruptions minAvailable: 1 worker: name: @@ -33,7 +31,5 @@ worker: resources: replicaCount: pdb: - # Set to false to disable creating the PDB for frontend - enabled: true - # Minimum number of frontend pods that must be available during disruptions + # (Optional) Minimum number of worker pods that must be available during disruptions minAvailable: 1 diff --git a/charts/argocd-apps/templates/frontend-pdb.yaml b/charts/argocd-apps/templates/frontend-pdb.yaml index 23c5415..03e661d 100644 --- a/charts/argocd-apps/templates/frontend-pdb.yaml +++ b/charts/argocd-apps/templates/frontend-pdb.yaml @@ -1,16 +1,18 @@ -{{- if and .Values.main.enabled .Values.main.pdb.enabled }} -apiVersion: policy/v1 +{{- $web := .Values.main }} +{{- $replicas := $web.replicaCount | default 1 }} +{{- if and $web.enabled (ge (int $replicas) 1) }}apiVersion: policy/v1 kind: PodDisruptionBudget metadata: - name: {{ .Values.main.name }}-frontend-pdb - namespace: {{ $.Release.Namespace | quote }} + name: {{ $web.name | default "web" }}-pdb labels: - app: {{ .Values.main.name | quote }} + app.kubernetes.io/name: {{ $web.name | default "web" }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} spec: - minAvailable: {{ .Values.main.pdb.minAvailable }} + minAvailable: {{ get (default dict $web.pdb) "minAvailable" | default 1 }} selector: matchLabels: - app.kubernetes.io/name: {{ .Values.main.name | quote }} + app.kubernetes.io/name: {{ $web.name | default "web" }} app.kubernetes.io/component: web app.kubernetes.io/part-of: {{ $.Release.Name | quote }} {{- end }} diff --git a/charts/argocd-apps/templates/worker-pdb.yaml b/charts/argocd-apps/templates/worker-pdb.yaml index f3dad3b..cd84e4d 100644 --- a/charts/argocd-apps/templates/worker-pdb.yaml +++ b/charts/argocd-apps/templates/worker-pdb.yaml @@ -1,16 +1,18 @@ -{{- if and .Values.worker.enabled .Values.worker.pdb.enabled }} -apiVersion: policy/v1 +{{- $worker := .Values.worker }} +{{- $replicas := $worker.replicaCount | default 1 }} +{{- if and $worker.enabled (ge (int $replicas) 1) }}apiVersion: policy/v1 kind: PodDisruptionBudget metadata: - name: {{ .Values.worker.name }}-worker-pdb - namespace: {{ $.Release.Namespace | quote }} + name: {{ $worker.name | default "worker" }}-pdb labels: - app: {{ .Values.worker.name | quote }} + app.kubernetes.io/name: {{ $worker.name | default "worker" }} + app.kubernetes.io/component: worker + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} spec: - minAvailable: {{ .Values.worker.pdb.minAvailable }} + minAvailable: {{ get (default dict $worker.pdb) "minAvailable" | default 1 }} selector: matchLabels: - app.kubernetes.io/name: {{ .Values.worker.name | quote }} + app.kubernetes.io/name: {{ $worker.name | default "worker" }} app.kubernetes.io/component: worker app.kubernetes.io/part-of: {{ $.Release.Name | quote }} {{- end }} diff --git a/charts/generic-service/Chart.yaml b/charts/generic-service/Chart.yaml index 13458ab..3b0347b 100644 --- a/charts/generic-service/Chart.yaml +++ b/charts/generic-service/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: generic-service description: A Helm chart for Kubernetes -version: 1.1.6-delta +version: 1.1.7 dependencies: - name: memcached version: 6.6.x diff --git a/charts/generic-service/Values.yaml b/charts/generic-service/Values.yaml index 6ba8ac6..1c14029 100644 --- a/charts/generic-service/Values.yaml +++ b/charts/generic-service/Values.yaml @@ -23,10 +23,8 @@ frontend: secretRef: php-app-tls # pragma: allowlist secret imagepolicy: pattern: ^DEVOPS-338-deploy-breeze-qa-api-[a-fA-F0-9]+-(?P.*) - pdb: - # Set to false to disable creating the PDB for frontend - enabled: true - # Minimum number of frontend pods that must be available during disruptions + pdb: + # (Optional) Minimum number of frontend pods that must be available during disruptions minAvailable: 1 worker: @@ -41,9 +39,7 @@ worker: imagepolicy: pattern: ^DEVOPS-338-deploy-breeze-qa-api-[a-fA-F0-9]+-(?P.*) pdb: - # Set to false to disable creating the PDB for frontend - enabled: true - # Minimum number of frontend pods that must be available during disruptions + # (Optional) Minimum number of worker pods that must be available during disruptions minAvailable: 1 autoscaling: diff --git a/charts/generic-service/templates/frontend-pdb.yaml b/charts/generic-service/templates/frontend-pdb.yaml index 17bdd28..b422c70 100644 --- a/charts/generic-service/templates/frontend-pdb.yaml +++ b/charts/generic-service/templates/frontend-pdb.yaml @@ -1,17 +1,19 @@ {{- range $key, $value := .Values.frontend }} - {{- if and $value.pdb.enabled $value.name }} -apiVersion: policy/v1 +{{- $replicas := $value.replicaCount | default 1 }} +{{- if and $value.enabled (ge (int $replicas) 1) }}apiVersion: policy/v1 kind: PodDisruptionBudget metadata: - name: {{ $value.name }}-frontend-pdb - namespace: {{ $.Release.Namespace | quote }} + name: {{ $value.name | default "web" }}-pdb labels: - app: {{ $value.name | quote }} + app.kubernetes.io/name: {{ $value.name | default "web" }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} spec: - minAvailable: {{ .Values.frontend.pdb.minAvailable }} + minAvailable: {{ get (default dict $value.pdb) "minAvailable" | default 1 }} selector: matchLabels: - app.kubernetes.io/name: {{ $value.name | quote }} + app.kubernetes.io/name: {{ $value.name | default "web" }} app.kubernetes.io/component: web app.kubernetes.io/part-of: {{ $.Release.Name | quote }} {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/generic-service/templates/worker-pdb.yaml b/charts/generic-service/templates/worker-pdb.yaml index 31c9730..7329802 100644 --- a/charts/generic-service/templates/worker-pdb.yaml +++ b/charts/generic-service/templates/worker-pdb.yaml @@ -1,17 +1,19 @@ {{- range $key, $value := .Values.worker }} - {{- if and $value.pdb.enabled $value.name }} -apiVersion: policy/v1 +{{- $replicas := $value.replicaCount | default 1 }} +{{- if and $value.enabled (ge (int $replicas) 1) }}apiVersion: policy/v1 kind: PodDisruptionBudget metadata: - name: {{ $value.name }}-worker-pdb - namespace: {{ $.Release.Namespace | quote }} + name: {{ $value.name | default "worker" }}-pdb labels: - app: {{ $value.name | quote }} + app.kubernetes.io/name: {{ $value.name | default "worker" }} + app.kubernetes.io/component: worker + app.kubernetes.io/part-of: {{ $.Release.Name | quote }} spec: - minAvailable: {{ .Values.worker.pdb.minAvailable }} + minAvailable: {{ get (default dict $value.pdb) "minAvailable" | default 1 }} selector: matchLabels: - app.kubernetes.io/name: {{ $value.name | quote }} + app.kubernetes.io/name: {{ $value.name | default "worker" }} app.kubernetes.io/component: worker app.kubernetes.io/part-of: {{ $.Release.Name | quote }} {{- end }} +{{- end }} From 5f54eb04064a687861cf838a015be1342eaf7446 Mon Sep 17 00:00:00 2001 From: David Wickstrom Date: Tue, 5 Aug 2025 13:10:40 -0400 Subject: [PATCH 3/3] merge main and resolve conflicts --- charts/argocd-apps/Chart.yaml | 2 +- charts/argocd-apps/Values.yaml | 73 +++++++++++++------ charts/argocd-apps/templates/autoscaler.yaml | 53 ++++++++++++++ charts/argocd-apps/templates/cronjob.yaml | 1 + .../templates/frontend-deployment.yaml | 7 +- .../argocd-apps/templates/migrations-job.yaml | 1 + .../templates/worker-deployment.yaml | 8 +- 7 files changed, 118 insertions(+), 27 deletions(-) create mode 100644 charts/argocd-apps/templates/autoscaler.yaml diff --git a/charts/argocd-apps/Chart.yaml b/charts/argocd-apps/Chart.yaml index 7e6cf6d..732b816 100644 --- a/charts/argocd-apps/Chart.yaml +++ b/charts/argocd-apps/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v2 name: argocd-app description: A Helm chart for applications using ArgoCD -version: 0.9.2 +version: 1.0.2 diff --git a/charts/argocd-apps/Values.yaml b/charts/argocd-apps/Values.yaml index 0bf2ae9..7a49f81 100644 --- a/charts/argocd-apps/Values.yaml +++ b/charts/argocd-apps/Values.yaml @@ -1,35 +1,60 @@ -project: -environment: +project: +environment: onepassworditems: - - name: - itemPath: - secretType: +- name: + itemPath: + secretType: +- name: + itemPath: main: - name: - enabled: - type: - image: - resources: {} - port: - replicaCount: + name: + enabled: + type: + image: + resources: + requests: + cpu: # in millicores + memory: # in mebibytes + limits: + cpu: # in millicores + memory: # in mebibytes + port: + envFrom: + - secretRef: + name: loadBalancer: - name: - targetGroupARN: - securityGroupID: + name: + targetGroupARN: + securityGroupID: + autoscaling: + enabled: + minReplicaCount: + maxReplicaCount: + cpuUtilizationPercentage: + memoryUtilizationPercentage: pdb: # (Optional) Minimum number of frontend pods that must be available during disruptions minAvailable: 1 worker: - name: - enabled: - type: - image: - command: - args: - - - pullPolicy: + name: + enabled: + type: + image: + command: + pullPolicy: resources: - replicaCount: + requests: + cpu: # in millicores + memory: # in mebibytes + limits: + cpu: # in millicores + memory: # in mebibytes + autoscaling: + enabled: + minReplicaCount: + maxReplicaCount: + cpuUtilizationPercentage: + memoryUtilizationPercentage: pdb: # (Optional) Minimum number of worker pods that must be available during disruptions minAvailable: 1 diff --git a/charts/argocd-apps/templates/autoscaler.yaml b/charts/argocd-apps/templates/autoscaler.yaml new file mode 100644 index 0000000..152f3c9 --- /dev/null +++ b/charts/argocd-apps/templates/autoscaler.yaml @@ -0,0 +1,53 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Values.main.name }}-autoscaler +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Values.main.name }} + minReplicas: {{ .Values.main.autoscaling.minReplicaCount }} + maxReplicas: {{ .Values.main.autoscaling.maxReplicaCount }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + # Formula is (limit/request) * desiredPercentage + averageUtilization: {{ div .Values.main.resources.limits.cpu .Values.main.resources.requests.cpu | mul .Values.main.autoscaling.cpuUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + # Formula is (limit/request) * desiredPercentage + averageUtilization: {{ div .Values.main.resources.limits.memory .Values.main.resources.requests.memory | mul .Values.main.autoscaling.memoryUtilizationPercentage }} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Values.worker.name }}-autoscaler +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Values.worker.name }} + minReplicas: {{ .Values.worker.autoscaling.minReplicaCount }} + maxReplicas: {{ .Values.worker.autoscaling.maxReplicaCount }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + # Formula is (limit/request) * desiredPercentage + averageUtilization: {{ div .Values.worker.resources.limits.cpu .Values.worker.resources.requests.cpu | mul .Values.worker.autoscaling.cpuUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + # Formula is (limit/request) * desiredPercentage + averageUtilization: {{ div .Values.worker.resources.limits.memory .Values.worker.resources.requests.memory | mul .Values.worker.autoscaling.memoryUtilizationPercentage }} diff --git a/charts/argocd-apps/templates/cronjob.yaml b/charts/argocd-apps/templates/cronjob.yaml index 03d5840..7775d38 100644 --- a/charts/argocd-apps/templates/cronjob.yaml +++ b/charts/argocd-apps/templates/cronjob.yaml @@ -1,6 +1,7 @@ {{- if .Values.cronjob }} {{- range $key, $value := .Values.cronjob }} {{- if eq $value.enabled true }} +--- apiVersion: batch/v1 kind: CronJob metadata: diff --git a/charts/argocd-apps/templates/frontend-deployment.yaml b/charts/argocd-apps/templates/frontend-deployment.yaml index de7a364..a23bf70 100644 --- a/charts/argocd-apps/templates/frontend-deployment.yaml +++ b/charts/argocd-apps/templates/frontend-deployment.yaml @@ -79,7 +79,12 @@ spec: containerPort: {{ .Values.main.port }} protocol: TCP resources: - {{- toYaml .Values.main.resources | nindent 12 }} + requests: + cpu: "{{ .Values.main.resources.requests.cpu }}m" + memory: "{{ .Values.main.resources.requests.memory }}Mi" + limits: + cpu: "{{ .Values.main.resources.limits.cpu }}m" + memory: "{{ .Values.main.resources.limits.memory }}Mi" volumeMounts: {{- range $key, $value := $.Values.keyinjection }} - name: {{ $value.name }} diff --git a/charts/argocd-apps/templates/migrations-job.yaml b/charts/argocd-apps/templates/migrations-job.yaml index 83557f9..fd380f0 100644 --- a/charts/argocd-apps/templates/migrations-job.yaml +++ b/charts/argocd-apps/templates/migrations-job.yaml @@ -1,6 +1,7 @@ {{- if .Values.migrations }} {{- range $key, $value := .Values.migrations }} {{- if eq $value.enabled true }} +--- apiVersion: batch/v1 kind: Job metadata: diff --git a/charts/argocd-apps/templates/worker-deployment.yaml b/charts/argocd-apps/templates/worker-deployment.yaml index 1244f4a..fbe262c 100644 --- a/charts/argocd-apps/templates/worker-deployment.yaml +++ b/charts/argocd-apps/templates/worker-deployment.yaml @@ -57,7 +57,13 @@ spec: - name: DD_PROFILING_ENABLED value: "true" envFrom: {{- toYaml .Values.worker.envFrom | nindent 12 }} - resources: {{- toYaml .Values.worker.resources | nindent 12 }} + resources: + requests: + cpu: "{{ .Values.worker.resources.requests.cpu }}m" + memory: "{{ .Values.worker.resources.requests.memory }}Mi" + limits: + cpu: "{{ .Values.worker.resources.limits.cpu }}m" + memory: "{{ .Values.worker.resources.limits.memory }}Mi" command: {{ .Values.worker.command }} args: {{- range .Values.worker.args }}