External metric in GKE with rabbimq queue length not working , giving error

11/4/2019

I'm trying to use HPA based on external metric in GKE but it's giving error - horizontal-pod-autoscaler unable to get external metric default/custom.googleapis.com|rabbitmq_queue_messages_ready/nil: unable to fetch metrics from external metrics API: the server is currently unable to handle the request (get custom.googleapis.com|rabbitmq_queue_messages_ready.external.metrics.k8s.io

I've setup an external metric in k8 cluster that sends data to google stackdriver. This metric contains info about number of message in a rabbitmq, this queue is out-of-the-cluster. Based on queue length, i'm trying to autoscale my pods. Now i'm able to push the data to stackdriver and can see the metric in Metric Explorer. But when i try to use this in my HPA, it gives error.

HPA -

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: exp-anno-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1beta1
    kind: Deployment
    name: exp-anno
  minReplicas: 2
  maxReplicas: 6
  metrics:
  - type: External
    external:
      metricName: "custom.googleapis.com|rabbitmq_queue_messages_ready"
      targetValue: 10
-- saurabh jain
google-kubernetes-engine
kubernetes

0 Answers