You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ga...@apache.org on 2023/04/19 06:04:00 UTC

[apisix-helm-chart] branch master updated: feat: support v2 version for hpa (#468)

This is an automated email from the ASF dual-hosted git repository.

gallardot pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git


The following commit(s) were added to refs/heads/master by this push:
     new 5092739  feat: support v2 version for hpa (#468)
5092739 is described below

commit 5092739f02dd9d29587ed319f797f23e0992c019
Author: Tristan <ji...@foxmail.com>
AuthorDate: Wed Apr 19 14:03:55 2023 +0800

    feat: support v2 version for hpa (#468)
    
    * feat: support v2 version for hpa
---
 charts/apisix-dashboard/README.md                  |  1 +
 charts/apisix-dashboard/templates/hpa.yaml         | 25 ++++++++++++++-
 charts/apisix-dashboard/values.yaml                |  2 ++
 charts/apisix-ingress-controller/README.md         |  1 +
 .../apisix-ingress-controller/templates/hpa.yaml   | 28 +++++++++++++++--
 charts/apisix-ingress-controller/values.yaml       |  2 ++
 charts/apisix/README.md                            |  1 +
 charts/apisix/templates/hpa.yaml                   | 36 ++++++++++++++++++----
 charts/apisix/values.yaml                          |  2 ++
 9 files changed, 89 insertions(+), 9 deletions(-)

diff --git a/charts/apisix-dashboard/README.md b/charts/apisix-dashboard/README.md
index 08ba8bb..b45176a 100644
--- a/charts/apisix-dashboard/README.md
+++ b/charts/apisix-dashboard/README.md
@@ -58,6 +58,7 @@ _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documen
 | autoscaling.maxReplicas | int | `100` | Maximum number of replicas to scale out |
 | autoscaling.minReplicas | int | `1` | Minimum number of replicas to scale back |
 | autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilization percentage |
+| autoscaling.version | string | `"v2"` | HPA version, the value is "v2" or "v2beta1", default "v2" |
 | config.authentication.expireTime | int | `3600` | JWT token expire time, in second |
 | config.authentication.secret | string | `"secret"` | Secret for jwt token generation |
 | config.authentication.users | list | `[{"password":"admin","username":"admin"}]` | Specifies username and password for login manager api. |
diff --git a/charts/apisix-dashboard/templates/hpa.yaml b/charts/apisix-dashboard/templates/hpa.yaml
index 9048605..8193005 100644
--- a/charts/apisix-dashboard/templates/hpa.yaml
+++ b/charts/apisix-dashboard/templates/hpa.yaml
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 {{- if .Values.autoscaling.enabled }}
-apiVersion: autoscaling/v2beta1
+apiVersion: autoscaling/{{ .Values.autoscaling.version }}
 kind: HorizontalPodAutoscaler
 metadata:
   name: {{ include "apisix-dashboard.fullname" . }}
@@ -30,6 +30,27 @@ spec:
   minReplicas: {{ .Values.autoscaling.minReplicas }}
   maxReplicas: {{ .Values.autoscaling.maxReplicas }}
   metrics:
+  {{- if eq .Values.autoscaling.version "v2" }}
+    {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: cpu
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+    {{- end }}
+
+    {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: memory
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+
+  {{- else }}
+
     {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
     - type: Resource
       resource:
@@ -42,4 +63,6 @@ spec:
         name: memory
         targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
     {{- end }}
+
+  {{- end}}
 {{- end }}
diff --git a/charts/apisix-dashboard/values.yaml b/charts/apisix-dashboard/values.yaml
index 9593033..ffc543d 100644
--- a/charts/apisix-dashboard/values.yaml
+++ b/charts/apisix-dashboard/values.yaml
@@ -155,6 +155,8 @@ resources: {}
 autoscaling:
   # -- Enable autoscaling for Apache APISIX Dashboard deployment
   enabled: false
+  # -- HPA version, the value is "v2" or "v2beta1", default "v2"
+  version: v2
   # -- Minimum number of replicas to scale back
   minReplicas: 1
   # -- Maximum number of replicas to scale out
diff --git a/charts/apisix-ingress-controller/README.md b/charts/apisix-ingress-controller/README.md
index 1ef70d3..90f84d1 100644
--- a/charts/apisix-ingress-controller/README.md
+++ b/charts/apisix-ingress-controller/README.md
@@ -109,6 +109,7 @@ The same for container level, you need to set:
 | autoscaling.maxReplicas | int | `100` |  |
 | autoscaling.minReplicas | int | `1` |  |
 | autoscaling.targetCPUUtilizationPercentage | int | `80` |  |
+| autoscaling.version | string | `"v2"` | HPA version, the value is "v2" or "v2beta1", default "v2" |
 | clusterDomain | string | `"cluster.local"` |  |
 | config.apisix | object | `{"adminAPIVersion":"v2","adminKey":"edd1c9f034335f136f87ad84b625c8f1","clusterName":"default","serviceName":"apisix-admin","serviceNamespace":"ingress-apisix","servicePort":9180}` | APISIX related configurations. |
 | config.apisix.adminAPIVersion | string | `"v2"` | the APISIX admin API version. can be "v2" or "v3", default is "v2". |
diff --git a/charts/apisix-ingress-controller/templates/hpa.yaml b/charts/apisix-ingress-controller/templates/hpa.yaml
index c7101c3..37bdb14 100644
--- a/charts/apisix-ingress-controller/templates/hpa.yaml
+++ b/charts/apisix-ingress-controller/templates/hpa.yaml
@@ -14,8 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-  {{- if .Values.autoscaling.enabled }}
-apiVersion: autoscaling/v2beta1
+
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/{{ .Values.autoscaling.version }}
 kind: HorizontalPodAutoscaler
 metadata:
   name: {{ include "apisix-ingress-controller.fullname" . }}
@@ -30,6 +31,27 @@ spec:
   minReplicas: {{ .Values.autoscaling.minReplicas }}
   maxReplicas: {{ .Values.autoscaling.maxReplicas }}
   metrics:
+  {{- if eq .Values.autoscaling.version "v2" }}
+    {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: cpu
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+    {{- end }}
+
+    {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: memory
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+
+  {{- else }}
+
     {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
     - type: Resource
       resource:
@@ -42,4 +64,6 @@ spec:
         name: memory
         targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
     {{- end }}
+
+  {{- end}}
 {{- end }}
diff --git a/charts/apisix-ingress-controller/values.yaml b/charts/apisix-ingress-controller/values.yaml
index 35fe842..0919863 100644
--- a/charts/apisix-ingress-controller/values.yaml
+++ b/charts/apisix-ingress-controller/values.yaml
@@ -147,6 +147,8 @@ initContainer:
 
 autoscaling:
   enabled: false
+  # -- HPA version, the value is "v2" or "v2beta1", default "v2"
+  version: v2
   minReplicas: 1
   maxReplicas: 100
   targetCPUUtilizationPercentage: 80
diff --git a/charts/apisix/README.md b/charts/apisix/README.md
index 642ae4b..6661326 100644
--- a/charts/apisix/README.md
+++ b/charts/apisix/README.md
@@ -94,6 +94,7 @@ The command removes all the Kubernetes components associated with the chart and
 | autoscaling.minReplicas | int | `1` |  |
 | autoscaling.targetCPUUtilizationPercentage | int | `80` |  |
 | autoscaling.targetMemoryUtilizationPercentage | int | `80` |  |
+| autoscaling.version | string | `"v2"` | HPA version, the value is "v2" or "v2beta1", default "v2" |
 | configurationSnippet | object | `{"httpAdmin":"","httpEnd":"","httpSrv":"","httpStart":"","main":"","stream":""}` | Custom configuration snippet. |
 | customPlugins | object | `{"enabled":false,"luaPath":"/opts/custom_plugins/?.lua","plugins":[{"attrs":{},"configMap":{"mounts":[{"key":"the-file-name","path":"mount-path"}],"name":"configmap-name"},"name":"plugin-name"}]}` | customPlugins allows you to mount your own HTTP plugins. |
 | customPlugins.enabled | bool | `false` | Whether to configure some custom plugins |
diff --git a/charts/apisix/templates/hpa.yaml b/charts/apisix/templates/hpa.yaml
index c1b123a..c994c88 100644
--- a/charts/apisix/templates/hpa.yaml
+++ b/charts/apisix/templates/hpa.yaml
@@ -14,8 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-{{- if (and .Values.apisix.enabled .Values.autoscaling.enabled) }}
-apiVersion: autoscaling/v2beta1
+{{- if and .Values.apisix.enabled .Values.autoscaling.enabled }}
+
+apiVersion: autoscaling/{{ .Values.autoscaling.version }}
 kind: HorizontalPodAutoscaler
 metadata:
   name: {{ include "apisix.fullname" . }}
@@ -30,16 +31,39 @@ spec:
   minReplicas: {{ .Values.autoscaling.minReplicas }}
   maxReplicas: {{ .Values.autoscaling.maxReplicas }}
   metrics:
-  {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+  {{- if eq .Values.autoscaling.version "v2" }}
+    {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: cpu
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+    {{- end }}
+
+    {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: memory
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+
+  {{- else }}
+
+    {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
     - type: Resource
       resource:
         name: cpu
         targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
-  {{- end }}
-  {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+    {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
     - type: Resource
       resource:
         name: memory
         targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
-  {{- end }}
+    {{- end }}
+
+  {{- end}}
 {{- end }}
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index 1569d26..8d8e8bf 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -480,6 +480,8 @@ initContainer:
 
 autoscaling:
   enabled: false
+  # -- HPA version, the value is "v2" or "v2beta1", default "v2"
+  version: v2
   minReplicas: 1
   maxReplicas: 100
   targetCPUUtilizationPercentage: 80