diff --git a/deploy/helm/Chart.yaml b/deploy/helm/Chart.yaml index 04d7136d985..ac4a693ec2e 100644 --- a/deploy/helm/Chart.yaml +++ b/deploy/helm/Chart.yaml @@ -11,7 +11,7 @@ sources: - https://github.com/appsmithorg/appsmith home: https://www.appsmith.com/ icon: https://assets.appsmith.com/appsmith-icon.png -version: 3.6.5 +version: 3.6.6 dependencies: - condition: redis.enabled name: redis diff --git a/deploy/helm/README.md b/deploy/helm/README.md index 8929dc22ba4..d1b6109784a 100644 --- a/deploy/helm/README.md +++ b/deploy/helm/README.md @@ -96,6 +96,12 @@ The command uninstalls the release and removes all Kubernetes resources associat | `tolerations` | Tolerations for pod assignment | `[]` | | `affinity` | Affinity fod pod assignment | `{}` | +#### Workload kind + +- `workload.kind`: Selects the workload resource to create. Allowed values: `Deployment`, `StatefulSet` (case-insensitive; default: `StatefulSet`). +- Note: When `autoscaling.enabled` is `true`, `workload.kind` is ignored and a `Deployment` is used. +- When using `Deployment` without autoscaling, control the number of replicas with `replicas`. + ### Appsmith service account parameters | Name | Description | Value | | ----------------------------- | ----------------------------------------------------------------------------------------------------------- | ------- | diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml index acbaa5e6e6d..2ea26e7b822 100644 --- a/deploy/helm/templates/deployment.yaml +++ b/deploy/helm/templates/deployment.yaml @@ -1,26 +1,29 @@ {{- $updateStrategy := .Values.updateStrategy | default dict }} {{- $postgresuser := .Values.postgresql.auth.username }} {{- $postgrespass := .Values.postgresql.auth.password }} -{{- $postgrespass := .Values.postgresql.auth.password }} {{- $releaseName := include "appsmith.fullname" . -}} +{{- $workloadKind := upper (toString .Values.workload.kind) -}} +{{- $useDeployment := or (eq $workloadKind "DEPLOYMENT") .Values.autoscaling.enabled }} apiVersion: apps/v1 -kind: {{ if not .Values.autoscaling.enabled }}StatefulSet{{- else }}Deployment{{- end }} +kind: {{ if $useDeployment }}Deployment{{- else }}StatefulSet{{- end }} metadata: name: {{ include "appsmith.fullname" . }} namespace: {{ include "appsmith.namespace" . }} labels: {{- include "appsmith.labels" . | nindent 4 }} spec: + {{- if $useDeployment }} {{- if not .Values.autoscaling.enabled }} - replicas: 1 - serviceName: {{ include "appsmith.fullname" . }} - updateStrategy: - {{- else }} + replicas: {{ .Values.replicas | default 1 }} + {{- end }} strategy: type: {{ .Values.strategyType | default "RollingUpdate" }} rollingUpdate: maxSurge: {{ dig "maxSurge" 1 $updateStrategy }} maxUnavailable: {{ dig "maxUnavailable" "0" $updateStrategy }} + {{- else }} + replicas: 1 + serviceName: {{ include "appsmith.fullname" . }} {{- end }} selector: matchLabels: @@ -182,7 +185,7 @@ spec: {{- if not .Values.persistence.enabled }} - name: data emptyDir: {} - {{- else if and (not .Values.autoscaling.enabled) (.Values.persistence.enabled) }} + {{- else if and (not $useDeployment) (.Values.persistence.enabled) }} volumeClaimTemplates: - metadata: name: data diff --git a/deploy/helm/templates/persistentVolume.yaml b/deploy/helm/templates/persistentVolume.yaml index c9655bed227..179e8c9db24 100644 --- a/deploy/helm/templates/persistentVolume.yaml +++ b/deploy/helm/templates/persistentVolume.yaml @@ -1,4 +1,6 @@ -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim.enabled) ( .Values.autoscaling.enabled) }} +{{- $workloadKind := upper (toString .Values.workload.kind) -}} +{{- $useDeployment := or (eq $workloadKind "DEPLOYMENT") .Values.autoscaling.enabled }} +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim.enabled) $useDeployment }} apiVersion: v1 kind: PersistentVolume metadata: diff --git a/deploy/helm/templates/persistentVolumeClaim.yaml b/deploy/helm/templates/persistentVolumeClaim.yaml index 21a774f3fbe..db8f4d5948b 100644 --- a/deploy/helm/templates/persistentVolumeClaim.yaml +++ b/deploy/helm/templates/persistentVolumeClaim.yaml @@ -1,4 +1,6 @@ -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim.enabled) ( .Values.autoscaling.enabled) }} +{{- $workloadKind := upper (toString .Values.workload.kind) -}} +{{- $useDeployment := or (eq $workloadKind "DEPLOYMENT") .Values.autoscaling.enabled }} +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim.enabled) $useDeployment }} kind: PersistentVolumeClaim apiVersion: v1 metadata: diff --git a/deploy/helm/tests/__snapshot__/defaults_snapshot_test.yaml.snap b/deploy/helm/tests/__snapshot__/defaults_snapshot_test.yaml.snap index d114faf2138..1316a3b5c25 100644 --- a/deploy/helm/tests/__snapshot__/defaults_snapshot_test.yaml.snap +++ b/deploy/helm/tests/__snapshot__/defaults_snapshot_test.yaml.snap @@ -25,7 +25,7 @@ app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: appsmith - appsmith.sh/chart: appsmith-3.6.5 + appsmith.sh/chart: appsmith-3.6.6 name: RELEASE-NAME-appsmith namespace: NAMESPACE 3: | @@ -36,7 +36,7 @@ app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: appsmith - appsmith.sh/chart: appsmith-3.6.5 + appsmith.sh/chart: appsmith-3.6.6 name: RELEASE-NAME-appsmith namespace: NAMESPACE spec: @@ -125,7 +125,6 @@ securityContext: {} serviceAccountName: RELEASE-NAME-appsmith volumes: null - updateStrategy: null volumeClaimTemplates: - metadata: name: data @@ -143,7 +142,7 @@ app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: appsmith - appsmith.sh/chart: appsmith-3.6.5 + appsmith.sh/chart: appsmith-3.6.6 name: RELEASE-NAME-appsmith-headless namespace: NAMESPACE spec: @@ -182,7 +181,7 @@ app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: appsmith - appsmith.sh/chart: appsmith-3.6.5 + appsmith.sh/chart: appsmith-3.6.6 name: RELEASE-NAME-appsmith namespace: NAMESPACE spec: @@ -203,7 +202,7 @@ app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: appsmith - appsmith.sh/chart: appsmith-3.6.5 + appsmith.sh/chart: appsmith-3.6.6 name: RELEASE-NAME-appsmith namespace: NAMESPACE secrets: diff --git a/deploy/helm/tests/persistence_test.yaml b/deploy/helm/tests/persistence_test.yaml new file mode 100644 index 00000000000..8d5b5785643 --- /dev/null +++ b/deploy/helm/tests/persistence_test.yaml @@ -0,0 +1,64 @@ +templates: + - persistentVolume.yaml + - persistentVolumeClaim.yaml +tests: + # Test PersistentVolume creation + - name: PV and PVC should be created when persistence enabled, no existing claim, and autoscaling enabled + set: + persistence: + enabled: true + existingClaim: + enabled: false + autoscaling: + enabled: true + asserts: + - isKind: + of: PersistentVolumeClaim + template: persistentVolumeClaim.yaml + - isKind: + of: PersistentVolume + template: persistentVolume.yaml + + - name: PVC should NOT be created when persistence is disabled + set: + persistence: + enabled: false + existingClaim: + enabled: false + autoscaling: + enabled: true + asserts: + - hasDocuments: + count: 0 + + - name: PV and PVC should not be created when using existing claim + set: + persistence: + enabled: true + existingClaim: + enabled: true + autoscaling: + enabled: true + asserts: + - hasDocuments: + count: 0 + + - name: PV and PVC should be created when setting workload kind to Deployment + set: + workload: + kind: Deployment + asserts: + - isKind: + of: PersistentVolumeClaim + template: persistentVolumeClaim.yaml + - isKind: + of: PersistentVolume + template: persistentVolume.yaml + + - name: PV and PVC should not be created when autoscaling is disabled and workload kind not set + set: + autoscaling: + enabled: false + asserts: + - hasDocuments: + count: 0 diff --git a/deploy/helm/tests/workload_type_test.yaml b/deploy/helm/tests/workload_type_test.yaml new file mode 100644 index 00000000000..3cb869b581a --- /dev/null +++ b/deploy/helm/tests/workload_type_test.yaml @@ -0,0 +1,33 @@ +templates: + - deployment.yaml +tests: + - name: workload type should be StatefulSet when not set + asserts: + - equal: + path: kind + value: StatefulSet + - name: workload type should be Deployment when set + set: + workload: + kind: Deployment + asserts: + - equal: + path: kind + value: Deployment + - name: replica count should be used when set + set: + workload: + kind: Deployment + replicas: 99 + asserts: + - equal: + path: spec.replicas + value: 99 + - name: workload type should be Deployment when autoscaling is enabled + set: + autoscaling: + enabled: true + asserts: + - equal: + path: kind + value: Deployment diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index e26e24eb4a4..45485d2c57f 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -271,6 +271,18 @@ resources: cpu: 500m memory: 3000Mi +## @param workload.kind Select workload resource type: Deployment or StatefulSet +## When set to Deployment, the chart creates a Deployment instead of a StatefulSet. +## Note: This value is ignored when autoscaling.enabled is true (Deployment is used). +## +workload: + kind: StatefulSet + +## @param replicas Number of replicas when autoscaling is disabled +## Only used when workload.kind is Deployment and autoscaling.enabled is false +## +replicas: 1 + autoscaling: enabled: false minReplicas: 2