<p>I'm attempting to configure a Horizontal Pod Autoscaler to scale a deployment based on the duty cycle of attached GPUs.</p>

<p>I'm using GKE, and my Kubernetes master version is 1.10.7-gke.6 .</p>

<p>I'm working off the tutorial at <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/external-metrics-autoscaling" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/external-metrics-autoscaling</a> .  In particular, I ran the following command to set up custom metrics:</p>

<pre><code>kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
</code></pre>

<p>This appears to have worked, or at least I can access a list of metrics at /apis/custom.metrics.k8s.io/v1beta1 .</p>

<p>This is my YAML:</p>

<pre><code>apiVersion: autoscaling/v2beta1                                            
kind: HorizontalPodAutoscaler                                              
metadata:                                                                  
  name: images-srv-hpa                                                     
spec:                                                                      
  minReplicas: 1                                                           
  maxReplicas: 10                                                          
  metrics:                                                                 
  - type: External                                                         
    external:                                                              
      metricName: container.googleapis.com|container|accelerator|duty_cycle
      targetAverageValue: 50                                               
  scaleTargetRef:                                                          
    apiVersion: apps/v1                                                    
    kind: Deployment                                                       
    name: images-srv-deployment
</code></pre>

<p>I believe that the metricName exists because it's listed in /apis/custom.metrics.k8s.io/v1beta1 , and because it's described on <a href="https://cloud.google.com/monitoring/api/metrics_gcp" rel="nofollow noreferrer">https://cloud.google.com/monitoring/api/metrics_gcp</a> .</p>

<p>This is the error I get when describing the HPA:</p>

<pre><code>  Type     Reason                        Age               From                       Message
  ----     ------                        ----              ----                       -------
  Warning  FailedGetExternalMetric       18s (x3 over 1m)  horizontal-pod-autoscaler  unable to get external metric prod/container.googleapis.com|container|accelerator|duty_cycle/nil: no metrics returned from external metrics API
  Warning  FailedComputeMetricsReplicas  18s (x3 over 1m)  horizontal-pod-autoscaler  failed to get container.googleapis.com|container|accelerator|duty_cycle external metric: unable to get external metric prod/container.googleapis.com|container|accelerator|duty_cycle/nil: no metrics returned from external metrics API
</code></pre>

<p>I don't really know how to go about debugging this.  Does anyone know what might be wrong, or what I could do next?</p>

<p>You are using ‘type: External’. For External Metrics List, you need to use ‘kubernetes.io’ instead of ‘container.googleapis.com’ [1]</p>

<p>Replace the ‘metricName:container.googleapis.com|container|accelerator|duty_cycle’ </p>

<p>with </p>

<p>‘metricName: kubernetes.io|container|accelerator|duty_cycle’</p>

<p>[1]<a href="https://cloud.google.com/monitoring/api/metrics_other#other-kubernetes.io" rel="nofollow noreferrer">https://cloud.google.com/monitoring/api/metrics_other#other-kubernetes.io</a></p>
