<p>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.</p>

<p>According to <a href="https://github.com/kubernetes/kubernetes/issues/69687" rel="nofollow noreferrer">this</a> I thought it would be working but it's not. I'm still facing : <code>The HorizontalPodAutoscaler "classifier" is invalid: spec.minReplicas: Invalid value: 0: must be greater than or equal to 1</code></p>

<p>Below is my HPA definition : </p>

<pre><code>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

</code></pre>

<p>Thanks a lot for your help !</p>

Thomas G
<blockquote>
<p>According to <a href="https://github.com/kubernetes/kubernetes/issues/69687" rel="noreferrer">this</a> I thought it would be working but it's not.</p>
</blockquote>
<p><strong>The fact that some features are working in the Kubernetes does not mean that they are enabled in managed solutions like <code>GKE</code>.</strong></p>
<p>This feature is enabled by a <strong>feature gate</strong>  called <strong><code>HPAScaleToZero</code></strong>. It is in <strong><code>Alpha</code></strong> 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: <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/" rel="noreferrer">Kubernetes.io: Docs: Feature Gates</a></p>
<p>Going further:</p>
<blockquote>
<p>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</p>
<p> <em><a href="https://cloud.google.com/kubernetes-engine/docs/concepts/kubernetes-engine-overview#kubernetes_versions_and_features" rel="noreferrer">Cloud.google.com: Kubernetes Engine: Kubernetes versions and features</a></em> </p>
</blockquote>
<p>As you can see by:</p>
<blockquote>
<p><code>The HorizontalPodAutoscaler &quot;classifier&quot; is invalid: spec.minReplicas: Invalid value: 0: must be greater than or equal to 1</code></p>
</blockquote>
<p><strong>This feature is disabled in &quot;standard&quot; <code>GKE</code> clusters.</strong></p>
<hr />
<p>There is an option to have <strong><code>HPAScaleToZero</code></strong> enabled. This entails running an <strong>alpha</strong> cluster:</p>
<blockquote>
<p>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.</p>
<p> <em><a href="https://cloud.google.com/kubernetes-engine/docs/concepts/alpha-clusters" rel="noreferrer">Cloud.google.com: Kubernetes Engine: Alpha clusters</a></em> </p>
</blockquote>
<p>Please have in mind that running <strong>alpha</strong> cluster have some drawbacks:</p>
<blockquote>
<h2>Limitations</h2>
<p>Alpha clusters have the following limitations:</p>
<ul>
<li><strong>Not covered by the GKE SLA</strong></li>
<li>Cannot be upgraded</li>
<li>Node auto-upgrade and auto-repair are disabled on alpha clusters</li>
<li><strong>Automatically deleted after 30 days</strong></li>
<li>Do not receive security updates</li>
</ul>
</blockquote>
