<p>I'm using a HPA based on a custom metric on GKE.</p>
<p>The HPA is not working and it's showing me this error log:</p>
<blockquote>
<p>unable to fetch metrics from custom metrics API: the server is currently unable to handle the request</p>
</blockquote>
<p>When I run <code>kubectl get apiservices | grep custom</code> I get</p>
<blockquote>
<p>v1beta1.custom.metrics.k8s.io            services/prometheus-adapter      False (FailedDiscoveryCheck)   135d</p>
</blockquote>
<p>this is the HPA spec config :</p>
<pre><code>spec:
  scaleTargetRef:
    kind: Deployment
    name: api-name
    apiVersion: apps/v1
  minReplicas: 3
  maxReplicas: 50
  metrics:
    - type: Object
      object:
        target:
          kind: Service
          name: api-name
          apiVersion: v1
        metricName: messages_ready_per_consumer
        targetValue: '1'
</code></pre>
<p>and this is the service's spec config :</p>
<pre><code>spec:
  ports:
    - name: worker-metrics
      protocol: TCP
      port: 8080
      targetPort: worker-metrics
  selector:
    app.kubernetes.io/instance: api
    app.kubernetes.io/name: api-name
  clusterIP: 10.8.7.9
  clusterIPs:
    - 10.8.7.9
  type: ClusterIP
  sessionAffinity: None
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
</code></pre>
<p>What should I do to make it work ?</p>

mohamed wael thabet
<p>Adding this block in my EKS nodes security group rules solved the issue for me:</p>
<pre><code>node_security_group_additional_rules = {
  ...
  ingress_cluster_metricserver = {
    description                   = &quot;Cluster to node 4443 (Metrics Server)&quot;
    protocol                      = &quot;tcp&quot;
    from_port                     = 4443
    to_port                       = 4443
    type                          = &quot;ingress&quot;
    source_cluster_security_group = true 
  }
  ...
}
</code></pre>
