Skip to content

rabbitmkube is an autoscaler for k8s deployments that need to base their number of replicas on the number of messages contained in a queue.

Notifications You must be signed in to change notification settings

taciomcosta/rabbitmkube

Repository files navigation

logo

rabbitmkube is an autoscaler for k8s deployments that need to base their number of replicas on the number of messages contained in a queue.

It is a simpler alternative to exporting custom-metrics to Kubernetes and creating HorizontalPodAutoScalers.

Requirements

You need to have RabbitMQ Manager plugin so that rabbitmkube can fetch RabbitMQ like this.

Step by Step

  1. Create a RoleBinding as shown in the command below:

kubectl create clusterrolebinding rabbitmkube --clusterrole=cluster-admin --serviceaccount=default:default

  1. Use the deployment.yaml file in this repository by changing its environment variable values.

  2. Add rabbitmkube annotations to your deployments as shown in the example below. messages-per-pod refers to the number of messages that a pod can take at once.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
  labels:
    app: example
  annotations:
    rabbitmkube/min-replicas: "0"
    rabbitmkube/max-replicas: "3"
    rabbitmkube/messages-per-pod: "1"
    rabbitmkube/queue-name: test-autoscaler
spec:                       
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: example/example

Done! Every 10 seconds rabbitmkube will look for deployments annotated with rabbitmkube values and add/remove new replicas to it.

About

rabbitmkube is an autoscaler for k8s deployments that need to base their number of replicas on the number of messages contained in a queue.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published