Giter Club home page Giter Club logo

k8s-rabbit-pod-autoscaler's Introduction

K8s autoscaler for pods that consume RabbitMQ

Autoscaling process (autoscale.sh):

  • Loops through deployments defined in AUTOSCALING (env var), every INTERVAL (env var) seconds.
  • Gets the messages queue on RabbitMQ for the current deployment's queue.
  • Calculates the amount of desired pods and scales the deployment if required.
  • Every event success or failure will log and notify slack if the SLACK_HOOK env var is set (logging intensity depends on LOGS env var).

This Pod runs in the kube-system namespace on k8s master nodes.

Requirements

  • The virtual host in RabbitMQ for queues has to be /.
  • Namespace(s), deployment(s) or queue(s) defined in AUTOSCALING env var can't have | or ; symbols in name(s).

Env vars

  • INTERVAL: Seconds between checks in the pod autoscaling process described above (default 30s)
  • RABBIT_HOST: RabbitMQ host (e.g. http://rabbitmq.example.com)
  • RABBIT_USER: Username used for authentication with the RabbitMQ API (check deploy.yml, defaults to rabbit-pod-autoscaler secret, rabbit-user key)
  • RABBIT_PASS: Password used for authentication with the RabbitMQ API (check deploy.yml, defaults to rabbit-pod-autoscaler secret, rabbit-pass key)
  • AUTOSCALING: Contains min/max pods, messages handled per pod, deployment info and queue name in the following pattern:
    • single deployment to autoscale: <minPods>|<maxPods>|<mesgPerPod>|<k8s namespace>|<k8s deployment name>|<RabbitMQ queue name>
      • e.g. 3|10|5|development|example|example.queue
      • mesgPerPod represents the amount of RabbitMQ messages a Pod can process within the INTERVAL (env var). As an example, if a Pod needs 6s to process a message from RabbitMQ, the mesgPerPod value will be INTERVAL (30s) / process time (6s) = 5.
    • multiple deployments to autoscale: check example deploy.yml
  • LOGS: Logging and Slack notifications intensity. Errors are logged and notified on every option
    • HIGH (default): Logs and notifies on every event
    • MEDIUM: Logs and notifies on min pods, avg pods ((min+max)/2) and max pods scale events
    • LOW: Logs and notifies on min pods and max pods scale events
  • SLACK_HOOK: Slack incoming webhook for event notifications

Deployment

kubectl --context CONTEXT -n kube-system apply -f deploy.yml

k8s-rabbit-pod-autoscaler's People

Contributors

adrianchifor avatar

Watchers

Michał Kłujszo avatar Jakub Zalewski avatar James Cloos avatar Piotr Klibert avatar Piotr Jaworski avatar Hubert Stachurski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.