Code Monkey home page Code Monkey logo

docker-swarm-service-autoscaler's Introduction

Docker swarm service autoscaler Build Status codecov

Scales the number of docker containers for service based on threshold(s) for metrics

Configuration

poll_interval_seconds: 60
metric_stores:
  - name: monitoring
    type: prometheus
    prometheus:
      url: http://localhost:9090
autoscale_rules:
  - service_name: example_web
    scale_min: 1
    scale_max: 3
    scale_step: 1
    metric_store: monitoring
    metric_query: scalar(avg(rate(http_requests_total{job="web"}[5m])))
    scale_up_threshold: 300
    scale_down_threshold: 200

Running

This service must be run on a docker swarm manager node if the connection to docker daemon needs to be established via /var/run/docker.sock

You can alternatively pass docker host url via DOCKER_HOST environment variable. You can pass environment variable DOCKER_TLS_VERIFY to verify the host against a CA certificate and DOCKER_CERT_PATH for specifying path to a directory containing TLS certificates to use when connecting to the Docker host.

Using code (local)

# Ensure python 2.x and pip installed
pip install -r app/requirements.txt
python -m app.main example/autoscaler.yml --log-level debug

Using docker

# Change example/autoscaler.yml as per your need
docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/example/autoscaler.yml:/etc/docker-swarm-service-autoscaler/autoscaler.yml sahajsoft/docker-swarm-service-autoscaler /etc/docker-swarm-service-autoscaler/autoscaler.yml --log-level=DEBUG

Running in docker swarm

services:
  autoscaler:
    image: sahajsoft/docker-swarm-service-autoscaler
    command: "/etc/docker-swarm-service-autoscaler/autoscaler.yml --log-leve=DEBUG"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    configs:
      - source: autoscaler.yml
        target: /etc/docker-swarm-service-autoscaler/autoscaler.yml
    deploy:
      placement:
        constraints:
          - node.role == manager

Example

Please checkout the examples here

Running tests

# Run tests
py.test
# Run tests and print coverage
py.test --cov=app
# Run tests and create html covergae report
py.test --cov=app --cov-report html
# Run tests automatically on any file change
ptw

Demo

Demo: Docker swarm service autoscaler

Metric stores

  • Prometheus (Supported)
  • InfluxDB (Pending): #4

Contributing

Please raise an issue for feature requests & bugs. Please submit a pull request to contribute code

docker-swarm-service-autoscaler's People

Contributors

endeepak avatar

Watchers

James Cloos 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.