From 2a1be9740e8f470d92f5066c4789e8f326f0906e Mon Sep 17 00:00:00 2001 From: Dev Jadeja Date: Tue, 11 Feb 2025 19:43:48 +0530 Subject: [PATCH 1/4] feature: capability to add extra kubernetes manifests example usage: ```yaml extraManifests: - apiVersion: v1 kind: LimitRange metadata: annotations: argocd.argoproj.io/sync-wave: "10" name: default-limit-range spec: limits: - default: memory: 700Mi defaultRequest: cpu: 50m memory: 500Mi type: Container ``` --- charts/py-app/templates/extra-objects.yaml | 6 ++++++ charts/py-app/values.yaml | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 charts/py-app/templates/extra-objects.yaml diff --git a/charts/py-app/templates/extra-objects.yaml b/charts/py-app/templates/extra-objects.yaml new file mode 100644 index 0000000..ee0aeb3 --- /dev/null +++ b/charts/py-app/templates/extra-objects.yaml @@ -0,0 +1,6 @@ +{{- if .Values.extraManifests }} +{{- range .Values.extraManifests }} +--- +{{ toYaml . }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/py-app/values.yaml b/charts/py-app/values.yaml index 2a11b42..a840187 100644 --- a/charts/py-app/values.yaml +++ b/charts/py-app/values.yaml @@ -125,3 +125,5 @@ autoscaling: maxReplicas: 20 targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 + +extraManifests: [] \ No newline at end of file From e412a20dd6f86f8b88705382b68fa8a481f66c00 Mon Sep 17 00:00:00 2001 From: Dev Jadeja Date: Tue, 11 Feb 2025 20:39:53 +0530 Subject: [PATCH 2/4] feature: added limitrange object support --- charts/py-app/templates/limitrange.yaml | 10 ++++++++++ charts/py-app/values.yaml | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 charts/py-app/templates/limitrange.yaml diff --git a/charts/py-app/templates/limitrange.yaml b/charts/py-app/templates/limitrange.yaml new file mode 100644 index 0000000..6bbf14b --- /dev/null +++ b/charts/py-app/templates/limitrange.yaml @@ -0,0 +1,10 @@ +{{- if .Values.limitRange.create }} +apiVersion: v1 +kind: LimitRange +metadata: + name: {{ include "py-app.fullname" . }} + labels: + {{- include "py-app.labels" . | nindent 4 }} +spec: + limits: {{ .Values.limitRange.limits | toYaml | nindent 2 }} +{{- end -}} \ No newline at end of file diff --git a/charts/py-app/values.yaml b/charts/py-app/values.yaml index a840187..25083fb 100644 --- a/charts/py-app/values.yaml +++ b/charts/py-app/values.yaml @@ -126,4 +126,13 @@ autoscaling: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 +limitRange: + create: false + # limits: + # - default: + # memory: 700Mi + # defaultRequest: + # cpu: 50m + # memory: 500Mi + # type: Container extraManifests: [] \ No newline at end of file From 474c501d5692e2ae4f2a80d548a1dc38c869c4b2 Mon Sep 17 00:00:00 2001 From: Dev Jadeja Date: Wed, 12 Feb 2025 11:33:08 +0530 Subject: [PATCH 3/4] added startupProbe support --- charts/py-app/templates/deployment.yaml | 3 +++ charts/py-app/templates/limitrange.yaml | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/charts/py-app/templates/deployment.yaml b/charts/py-app/templates/deployment.yaml index 6b13ecb..01a33b2 100644 --- a/charts/py-app/templates/deployment.yaml +++ b/charts/py-app/templates/deployment.yaml @@ -49,6 +49,9 @@ spec: {{- with .Values.probes.readiness }} readinessProbe: {{ . | toYaml | nindent 12 }} {{- end }} + {{- with .Values.probes.startup }} + startupProbe: {{ . | toYaml | nindent 12 }} + {{- end }} {{- include "py-app.envs" . | indent 10 -}} resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/py-app/templates/limitrange.yaml b/charts/py-app/templates/limitrange.yaml index 6bbf14b..b528383 100644 --- a/charts/py-app/templates/limitrange.yaml +++ b/charts/py-app/templates/limitrange.yaml @@ -6,5 +6,7 @@ metadata: labels: {{- include "py-app.labels" . | nindent 4 }} spec: - limits: {{ .Values.limitRange.limits | toYaml | nindent 2 }} -{{- end -}} \ No newline at end of file + {{- with .Values.limitRange.limits }} + limits: {{ . | toYaml | nindent 2 }} + {{- end }} +{{- end -}} From cb7070ac1de9df324782343ddc535aec840193f8 Mon Sep 17 00:00:00 2001 From: Dev Jadeja Date: Wed, 12 Feb 2025 12:22:36 +0530 Subject: [PATCH 4/4] features: revisionHistoryLimit and taskiq specific resources specification --- charts/py-app/templates/deployment.yaml | 4 ++++ charts/py-app/templates/taskiq-scheduler.yaml | 2 +- charts/py-app/templates/taskiq-worker.yaml | 2 +- charts/py-app/values.yaml | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/charts/py-app/templates/deployment.yaml b/charts/py-app/templates/deployment.yaml index 01a33b2..4533e17 100644 --- a/charts/py-app/templates/deployment.yaml +++ b/charts/py-app/templates/deployment.yaml @@ -8,6 +8,7 @@ metadata: spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit | default 5 }} {{- end }} {{- with .Values.updateStrategy }} strategy: @@ -53,6 +54,9 @@ spec: startupProbe: {{ . | toYaml | nindent 12 }} {{- end }} {{- include "py-app.envs" . | indent 10 -}} + {{- with .Values.securityContext }} + securityContext: {{ . | toYaml | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/py-app/templates/taskiq-scheduler.yaml b/charts/py-app/templates/taskiq-scheduler.yaml index fa6ac05..d92cf73 100644 --- a/charts/py-app/templates/taskiq-scheduler.yaml +++ b/charts/py-app/templates/taskiq-scheduler.yaml @@ -33,5 +33,5 @@ spec: command: {{ .Values.taskiq.schedulerCmd | toYaml | nindent 10 }} {{- include "py-app.envs" . | indent 10 -}} resources: - {{- toYaml .Values.resources | nindent 12 }} + {{- toYaml .Values.taskiq.resources | nindent 12 }} {{- end }} diff --git a/charts/py-app/templates/taskiq-worker.yaml b/charts/py-app/templates/taskiq-worker.yaml index 31712e5..a9ec44b 100644 --- a/charts/py-app/templates/taskiq-worker.yaml +++ b/charts/py-app/templates/taskiq-worker.yaml @@ -39,5 +39,5 @@ spec: command: {{ .Values.taskiq.workerCmd | toYaml | nindent 10 }} {{- include "py-app.envs" . | indent 10 -}} resources: - {{- toYaml .Values.resources | nindent 12 }} + {{- toYaml .Values.taskiq.resources | nindent 12 }} {{- end }} diff --git a/charts/py-app/values.yaml b/charts/py-app/values.yaml index 25083fb..0e2db73 100644 --- a/charts/py-app/values.yaml +++ b/charts/py-app/values.yaml @@ -30,6 +30,7 @@ ttlSecondsAfterFinished: 3600 taskiq: workerCmd: [] schedulerCmd: [] + resources: {} workers: 1 autoscaling: enabled: false