Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.2k views
in Technique[技术] by (71.8m points)

kubernetes - Autoscaling in GKE based on RabbitMQ Queue Size

I am very new to both Kubernetes and RabbitMQ, but I am attempting to autoscale pods based on the number of ready messages in my RabbitMQ queue.

I have been following the GCP documentation here and my prometheus rabbitmq container is based on the one found here

From these guides I have created a deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: rabbitmq-prometheus-sd
  name: rabbitmq-prometheus-sd
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      run: rabbitmq-prometheus-sd
  template:
    metadata:
      labels:
        run: rabbitmq-prometheus-sd
    spec:
      containers:
      # rabbitmq-exporter container
      - name: prometheus
        image: kbudde/rabbitmq-exporter:v0.29.0
        env:
          - name: RABBIT_URL
            value: http://MYRABBITMQHOST.rmq.cloudamqp.com:15672
          - name: RABBIT_USER
            value: MYRABBITMQUSERNAME
          - name: RABBIT_PASSWORD
            value: MYRABBITMQPASSWORD
          - name: PUBLISH_PORT
            value: "9419"
          # amqp 3.6.9++
          - name: RABBIT_CAPABILITIES
            value: "bert,no_sort"
      # pre-built 'prometheus-to-sd' sidecar container to export prometheus
      # metrics to Stackdriver
      - name: prometheus-to-sd
        image: gcr.io/google-containers/prometheus-to-sd:v0.5.0
        command: ["/monitor"]
        args:
        - --source=:http://localhost:9419
        - --stackdriver-prefix=custom.googleapis.com
        - --pod-id=$(POD_ID)
        - --namespace-id=$(POD_NAMESPACE)
        env:
        # save Kubernetes metadata as environment variables for use in metrics
        - name: POD_ID
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.uid
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace

I am able to deploy this to my cluster in GKE, however when I check the custom metrics in the metric explorer I can only find these 3 and none others:

  • rabbitmq_exporter_build_info
  • rabbitmq_module_up
  • rabbitmq_up

Obviously without the queue metrics I cannot create a HPA to scale my application. Any help or guidance on why these metrics are not being delivered or suggested alternate routes would be appreciated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The issue was that the rabbitmq exporter does not work with rabbitmq hosted on cloudampq. This method to scale was used instead


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...