From 5cc0feb647abe6d9ab5dedf8c14fc4a7cade9f86 Mon Sep 17 00:00:00 2001 From: Kris Lendon <36480650+tenkian4@users.noreply.github.com> Date: Mon, 18 Sep 2023 23:16:52 +0100 Subject: [PATCH] feat(helm): Support HPA for supersetNode and supersetWorker (#25280) Co-authored-by: Nav_InverseInfinity --- helm/superset/Chart.yaml | 2 +- helm/superset/README.md | 10 +++- .../superset/templates/deployment-worker.yaml | 2 + helm/superset/templates/deployment.yaml | 2 + helm/superset/templates/hpa-node.yaml | 54 +++++++++++++++++++ helm/superset/templates/hpa-worker.yaml | 54 +++++++++++++++++++ helm/superset/values.yaml | 14 +++++ 7 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 helm/superset/templates/hpa-node.yaml create mode 100644 helm/superset/templates/hpa-worker.yaml diff --git a/helm/superset/Chart.yaml b/helm/superset/Chart.yaml index 8af3ae4ac..729a5114c 100644 --- a/helm/superset/Chart.yaml +++ b/helm/superset/Chart.yaml @@ -29,7 +29,7 @@ maintainers: - name: craig-rueda email: craig@craigrueda.com url: https://github.com/craig-rueda -version: 0.10.6 +version: 0.10.7 dependencies: - name: postgresql version: 12.1.6 diff --git a/helm/superset/README.md b/helm/superset/README.md index 724eb4310..1b2588cbc 100644 --- a/helm/superset/README.md +++ b/helm/superset/README.md @@ -23,7 +23,7 @@ NOTE: This file is generated by helm-docs: https://github.com/norwoodj/helm-docs # superset -![Version: 0.10.6](https://img.shields.io/badge/Version-0.10.6-informational?style=flat-square) +![Version: 0.10.7](https://img.shields.io/badge/Version-0.10.7-informational?style=flat-square) Apache Superset is a modern, enterprise-ready business intelligence web application @@ -169,6 +169,10 @@ helm install my-superset superset/superset | supersetCeleryFlower.startupProbe.timeoutSeconds | int | `1` | | | supersetCeleryFlower.topologySpreadConstraints | list | `[]` | TopologySpreadConstrains to be added to supersetCeleryFlower deployments | | supersetNode.affinity | object | `{}` | Affinity to be added to supersetNode deployment | +| supersetNode.autoscaling.enabled | bool | `false` | | +| supersetNode.autoscaling.maxReplicas | int | `100` | | +| supersetNode.autoscaling.minReplicas | int | `1` | | +| supersetNode.autoscaling.targetCPUUtilizationPercentage | int | `80` | | | supersetNode.command | list | See `values.yaml` | Startup command | | supersetNode.connections.db_host | string | `"{{ .Release.Name }}-postgresql"` | | | supersetNode.connections.db_name | string | `"superset"` | | @@ -257,6 +261,10 @@ helm install my-superset superset/superset | supersetWebsockets.strategy | object | `{}` | | | supersetWebsockets.topologySpreadConstraints | list | `[]` | TopologySpreadConstrains to be added to supersetWebsockets deployments | | supersetWorker.affinity | object | `{}` | Affinity to be added to supersetWorker deployment | +| supersetWorker.autoscaling.enabled | bool | `false` | | +| supersetWorker.autoscaling.maxReplicas | int | `100` | | +| supersetWorker.autoscaling.minReplicas | int | `1` | | +| supersetWorker.autoscaling.targetCPUUtilizationPercentage | int | `80` | | | supersetWorker.command | list | a `celery worker` command | Worker startup command | | supersetWorker.containerSecurityContext | object | `{}` | | | supersetWorker.deploymentAnnotations | object | `{}` | Annotations to be added to supersetWorker deployment | diff --git a/helm/superset/templates/deployment-worker.yaml b/helm/superset/templates/deployment-worker.yaml index 7f2bcf8df..d84e7e956 100644 --- a/helm/superset/templates/deployment-worker.yaml +++ b/helm/superset/templates/deployment-worker.yaml @@ -34,7 +34,9 @@ metadata: annotations: {{- toYaml .Values.supersetWorker.deploymentAnnotations | nindent 4 }} {{- end }} spec: + {{- if not .Values.supersetWorker.autoscaling.enabled }} replicas: {{ .Values.supersetWorker.replicaCount }} + {{- end }} selector: matchLabels: app: {{ template "superset.name" . }}-worker diff --git a/helm/superset/templates/deployment.yaml b/helm/superset/templates/deployment.yaml index 780ae8796..19a32d706 100644 --- a/helm/superset/templates/deployment.yaml +++ b/helm/superset/templates/deployment.yaml @@ -34,7 +34,9 @@ metadata: annotations: {{- toYaml .Values.supersetNode.deploymentAnnotations | nindent 4 }} {{- end }} spec: + {{- if not .Values.supersetNode.autoscaling.enabled }} replicas: {{ .Values.supersetNode.replicaCount }} + {{- end }} {{- if .Values.supersetNode.strategy }} strategy: {{- toYaml .Values.supersetNode.strategy | nindent 4 }} {{- end }} diff --git a/helm/superset/templates/hpa-node.yaml b/helm/superset/templates/hpa-node.yaml new file mode 100644 index 000000000..aee2d1da7 --- /dev/null +++ b/helm/superset/templates/hpa-node.yaml @@ -0,0 +1,54 @@ +{{/* + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/}} + +{{- if .Values.supersetNode.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "superset.fullname" . }}-hpa + labels: + app: {{ template "superset.name" . }} + chart: {{ template "superset.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "superset.fullname" . }} + minReplicas: {{ .Values.supersetNode.autoscaling.minReplicas }} + maxReplicas: {{ .Values.supersetNode.autoscaling.maxReplicas }} + metrics: + {{- if .Values.supersetNode.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.supersetNode.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.supersetNode.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.supersetNode.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/helm/superset/templates/hpa-worker.yaml b/helm/superset/templates/hpa-worker.yaml new file mode 100644 index 000000000..f2fd2154a --- /dev/null +++ b/helm/superset/templates/hpa-worker.yaml @@ -0,0 +1,54 @@ +{{/* + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/}} + +{{- if .Values.supersetWorker.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "superset.fullname" . }}-hpa-worker + labels: + app: {{ template "superset.name" . }} + chart: {{ template "superset.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "superset.fullname" . }}-worker + minReplicas: {{ .Values.supersetWorker.autoscaling.minReplicas }} + maxReplicas: {{ .Values.supersetWorker.autoscaling.maxReplicas }} + metrics: + {{- if .Values.supersetWorker.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.supersetWorker.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.supersetWorker.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.supersetWorker.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/helm/superset/values.yaml b/helm/superset/values.yaml index 660aac8af..921033dc4 100644 --- a/helm/superset/values.yaml +++ b/helm/superset/values.yaml @@ -240,6 +240,13 @@ hostAliases: [] # Superset node configuration supersetNode: replicaCount: 1 + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + # -- Startup command # @default -- See `values.yaml` command: @@ -334,6 +341,13 @@ supersetNode: # Superset Celery worker configuration supersetWorker: replicaCount: 1 + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + # -- Worker startup command # @default -- a `celery worker` command command: