Thresholds: < 30% on average service will scale down and 70% > will scale up
To run this script, you must install the following packages.
apt install python3
pip install docker
# Using once
python3 auto-scaling.py
# Using every X seconds
python3 auto-scaling.py -t 30
# Using CRON
# It'll run every minutes
* * * * * python3 auto-scaling.py
# Using TIMER
# It'll run every minutes
#scaling.service
[Unit]
Description=Docker scaling script
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /.../auto-scaling.py
#scaling.timer
[Unit]
Description=Docker scaling script
[Timer]
OnCalendar=*-*-* *:*:00
[Install]
WantedBy=timers.target
# CLI
systemctl enable /.../scaling.timer