Creating scaling job
Let's try to translate the commands we executed manually into a Jenkins job. If we manage to do that, we can go further and let Alertmanager trigger that job whenever certain thresholds are reached in Prometheus.
We'll start by downloading Jenkins stack from the vfarcic/docker-flow-monitor
(https://github.com/vfarcic/docker-flow-monitor) repository.
curl-o jenkins.yml \ https://raw.githubusercontent.com/vfarcic/docker-\ flow-monitor/master/stacks/jenkins-aws-secret.yml catjenkins.yml
The stack definition we just downloaded is almost identical to the one we used before so we'll comment only the differences.
version: "3.2" services: ... agent: image: vfarcic/jenkins-swarm-agent ... secrets: - aws ... secrets: aws: external: true ...
The only new addition to the Jenkins stack is the aws
secret. It should contain AWS keys and the region we'll need for AWS CLI. So, let's start by creating the secret.
sourcecreds echo" export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID export...