简体   繁体   中英

HPA scale deployment to 0 on GKE

I'm trying to use HPA with external metrics to scale down a deployment to 0. I'm using GKE with version 1.16.9-gke.2.

According to this I thought it would be working but it's not. I'm still facing: The HorizontalPodAutoscaler "classifier" is invalid: spec.minReplicas: Invalid value: 0: must be greater than or equal to 1

Below is my HPA definition:

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: classifier
spec:
  minReplicas: 0
  maxReplicas: 15
  metrics:
  - external:
      metricName: loadbalancing.googleapis.com|https|request_count
      targetAverageValue: "1"
    type: External
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: classifier

Thanks a lot for your help !

According to this I thought it would be working but it's not.

The fact that some features are working in the Kubernetes does not mean that they are enabled in managed solutions like GKE .

This feature is enabled by a feature gate called HPAScaleToZero . It is in Alpha state since Kubernetes version 1.16. It is disabled by default according to below link. Please take a look on official documentation regarding feature gates here: Kubernetes.io: Docs: Feature Gates

Going further:

New features in Kubernetes are listed as Alpha, Beta, or Stable, depending upon their status in development. In most cases, Kubernetes features that are listed as Beta or Stable are included with GKE

Cloud.google.com: Kubernetes Engine: Kubernetes versions and features

As you can see by:

The HorizontalPodAutoscaler "classifier" is invalid: spec.minReplicas: Invalid value: 0: must be greater than or equal to 1

This feature is disabled in "standard" GKE clusters.


There is an option to have HPAScaleToZero enabled. This entails running an alpha cluster:

The term alpha cluster means that alpha APIs are enabled, both for Kubernetes and GKE, regardless of the version of Kubernetes the cluster runs. Periodically, Google offers customers the ability to test GKE versions that are not generally available, for testing and validation.

Cloud.google.com: Kubernetes Engine: Alpha clusters

Please have in mind that running alpha cluster have some drawbacks:

Limitations

Alpha clusters have the following limitations:

  • Not covered by the GKE SLA
  • Cannot be upgraded
  • Node auto-upgrade and auto-repair are disabled on alpha clusters
  • Automatically deleted after 30 days
  • Do not receive security updates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM