Using Drone-autoscaler in your already configured environment on AWS

In this Article, just an Update of the article Quick Drone Install with SSL , we will add Drone-Autoscaler to the installation and thus having a complete environment to start your CI Pipelines:

version: '3.8'
services:
  drone-server:
    image: drone/drone:latest
    container_name: drone
    volumes:
        - CHANGE_ME:/var/lib/drone/
        - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    environment:
        - DRONE_DEBUG=true
        - DRONE_LOGS_TRACE=true
        - DRONE_ORGS=CHANGE_ME
        - DRONE_RUNNER_CAPACITY=20
        - DRONE_AGENTS_ENABLED=true
        - DRONE_GITHUB_SERVER=https://github.com
        - DRONE_GITHUB_CLIENT_ID=CHANGE_ME
        - DRONE_GITHUB_CLIENT_SECRET=CHANGE_ME
        - DRONE_USER_CREATE=CHANGE_ME
        - DRONE_RPC_SECRET=CHANGE_ME
        - DRONE_OPEN=false
        - DRONE_GITHUB=true
        - DRONE_ADMIN_ALL=false
        - DRONE_SERVER_HOST=drone.vinicima.com #CHANGE_ME
        - DRONE_SERVER_PROTO=http
        - DRONE_CONVERT_MULTI=false
  npm:
    image: jc21/nginx-proxy-manager:latest
    container_name: npm
    ports:
        - 80:80
        - 443:443
        - 81:81
    environment:
        - X_FRAME_OPTIONS="sameorigin"
    volumes:
        - CHANGE_ME:/data
        - CHANGE_ME:/etc/letsencrypt
        - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
  drone-agent:
    image: drone/drone-runner-docker:latest
    container_name: drone-docker-runner
    volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /etc/localtime:/etc/localtime:ro
    environment:
        - DRONE_RPC_PROTO=https
        - DRONE_RPC_HOST=drone.vinicima.com #CHANGE_ME
        - DRONE_RUNNER_CAPACITY=20
        - DRONE_RPC_SECRET=CHANGE_ME
        - DRONE_DEFER_TAIL_LOG=true
        - DRONE_DEBUG=true
        - DRONE_RUNNER_NAME=drone-runner.vinicima.com#CHANGE_ME
  drone-autoscaler:
    image: drone/autoscaler:latest
    container_name: drone-autoscaler
    depends_on:
        - drone-server
    environment:
        - DRONE_SERVER_PROTO=https
        - DRONE_POOL_MIN=2
        - DRONE_POOL_MAX=4
        - DRONE_POOL_MIN_AGE=60m
        - DRONE_CAPACITY_BUFFER=1
        - DRONE_SERVER_HOST=drone.vinicima.com #CHANGEME
        - DRONE_SERVER_TOKEN=CHANGEME #CHANGEME
        - DRONE_AGENT_TOKEN=CHANGEME #CHANGEME
        - DRONE_AGENT_CONCURRENCY=2
        - DRONE_AGENT_IMAGE=drone/drone-runner-docker:latest
        - DRONE_AMAZON_REGION=us-east-2 #CHANGEME
        - DRONE_AMAZON_SUBNET_ID=AWS_subnet_id #CHANGEME
        - DRONE_AMAZON_SECURITY_GROUP:=sg-example #CHANGEME
        - DRONE_AMAZON_IMAGE=CHANGEME
        - DRONE_AMAZON_VOLUME_SIZE=40g #CHANGEME
        - DRONE_AMAZON_INSTANCE=t3.large #AWS Instance type
        - DRONE_AMAZON_SSHKEY=example-ssh-name #CHANGEME ( ssh-key that you will use to connect the instance)
        - DRONE_AMAZON_TAGS=TAGSAWS #CHANGEME
        - DRONE_INTERVAL=30s
        - DRONE_ENABLE_REAPER=true
        - DRONE_LOGS_DEBUG=true
        - DRONE_AGENT_VOLUMES=/root/.docker:/root/.docker
        - AWS_ACCESS_KEY_ID=XHAMSIDHDIDHD #CHANGEME
        - AWS_SECRET_ACCESS_KEY=xbdhdbssndsdsjnfbdfudfdfdughdgdjgd #CHANGEME
    volumes:
        - /etc/localtime:/etc/localtime:ro

In this configuration example above, the Drone-Autoscaler will leave two instances, being able to increase it to four Instances and run 2 simultaneous jobs per instance.
It is worth remembering that you must add your AWS account config so the Drone-Autoscaler can find it.
Also, remember to release TCP port 2375 for the Drone-Autoscaler address.

Run docker-compose:

#docker-compose up -d

That’s all! your environment will be complete to start your CI pipelines with Drone-autoscaler.

2 Likes