Another Autoscaler is a Kubernetes controller that automatically starts, stops, or restarts pods from a deployment at a specified time using a cron annotation.

Overview

Another Autoscaler

Another Autoscaler is a Kubernetes controller that automatically starts, stops, or restarts pods from a deployment at a specified time using a cron syntax.

Another Autoscaler read the annotation of each deployment and performs an increase or decrease in the number of replicas.

Docker image Kubernetes YAML manifests codebeat badge release license

The date and time must be in UTC.

The restart feature execute a rollout restart deployment.

Use cases

  • Cost savings by reducing the number of replicas after working hours or weekends.
  • GPU deployments stop them after working hours (this is my case in my current job).
  • Another Autoscaler is a perfect combination with Cluster Autoscaler.

Install

# Deploy Another Autoscaler into Kubernetes on default namespace
kubectl apply -f https://raw.githubusercontent.com/dignajar/another-autoscaler/master/kubernetes/full.yaml

Annotations

Stop pods at 6pm every day:

another-autoscaler.io/stop-time: "00 18 * * *"

Start pods at 1pm every day:

another-autoscaler.io/start-time: "00 13 * * *"

Start 3 pods at 2:30pm every day:

another-autoscaler.io/start-time: "30 14 * * *"
another-autoscaler.io/start-replicas: "3"

Restart pods at 9:15am every day:

another-autoscaler.io/restart-time: "15 09 * * *"

Restart pods at 2:30am, only on Saturday and Sunday:

another-autoscaler.io/restart-time: "00 02 * * 0,6"

Example: How to start pods at 2pm and stop them at 3pm every day

The following example start 5 replicas in total at 2pm and stop 4 of them at 3pm every day, the deployment start with 0 replicas.

The start-replicas is not incremental, the value is the number of replicas will be setup by Another Autoscaler at the defined time by start-time.

The date and time must be in UTC.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
  annotations:
    another-autoscaler.io/start-time: "00 14 * * *"
    another-autoscaler.io/start-replicas: "5"
    another-autoscaler.io/stop-time: "00 15 * * *"
    another-autoscaler.io/stop-replicas: "1"
spec:
  replicas: 0
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

GitOps / FluxCD

To avoid conflicts with Flux and Another Autoscaler, you can remove the field spec.replicas from your deployment manifest and leave Another Autoscaler to manage the number of replicas.

You might also like...
Plays air warning sound when detects a certain phrase or a word in a specified Telegram chat.

Tryvoha Bot Disclaimer: this is more a convenient naming, rather than a real bot. It is designed to play air warning sound when detects a certain phra

Lamblayer: a minimal deployment tool for AWS Lambda layers

lamblayer lamblayer is a minimal deployment tool for AWS Lambda layers. lamblayer does, Create a Layers of built pip-installable python packages. Crea

A discord.py bot template with easy deployment through Github Actions
A discord.py bot template with easy deployment through Github Actions

discord.py bot template A discord.py bot template with easy deployment through Github Actions. You can use this template to just run a Python instance

BioThings API framework - Making high-performance API for biological annotation data

BioThings SDK Quick Summary BioThings SDK provides a Python-based toolkit to build high-performance data APIs (or web services) from a single data sou

A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster
A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster

tokeks A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster. No AWS CLI, third-party client or library (boto3, botoc

A Python script that exports users from one Telegram group to another using one or more concurrent user bots.

ExportTelegramUsers A Python script that exports users from one Telegram group to another using one or more concurrent user bots. Make sure to set all

Transcript-Extractor-Bot - Yet another Telegram Voice Recognition bot but using vosk and supports 20+ languages

transcript extractor Yet another Telegram Voice Recognition bot but using vosk a

Powerful Telegram userbot to turn your PROFILE PICTURE & LAST NAME into a real time clock & to change your BIO automatically.
Powerful Telegram userbot to turn your PROFILE PICTURE & LAST NAME into a real time clock & to change your BIO automatically.

DATE_TIME_USERBOT-TeLeTiPs Powerful Telegram userbot to turn your PROFILE PICTURE & LAST NAME into a real time clock & to change your BIO automaticall

JAKYM, Just Another Konsole YouTube-Music. A command line based Youtube music player written in Python with spotify and youtube playlist support
JAKYM, Just Another Konsole YouTube-Music. A command line based Youtube music player written in Python with spotify and youtube playlist support

Just Another Konsole YouTube-Music Overview I wanted to create this application so that I could use the command line to play music easily. I often pla

Comments
  • Refactor code and allow cronjob suspention

    Refactor code and allow cronjob suspention

    I've implemented cronjob logic for enable and suspend them on start and stop time.

    A lot of code refactor also is included.

    I am already using this logic, and it may useful upstream.

    opened by margori 0
  • Support annotations errors

    Support annotations errors

    If there is an error in an annotation, service stops completely.

    'another-autoscaler/stop-time': '1-59/2 * * *' <- missing last column
    'another-autoscaler/stop-replicas': '' <- empty string is not an integer
    
    opened by margori 1
Releases(0.7)
  • 0.7(Nov 29, 2021)

  • 0.6(Oct 5, 2021)

  • 0.5(Oct 5, 2021)

    • Update Python 3.9.7
    • Rename annotations from another-autoscaler.io to another-autoscaler
    • Add ApiException to catch exceptions from K8s API
    • K8s manifests add namespace another and deploy Another Autoscaler in this new namespace
    Source code(tar.gz)
    Source code(zip)
  • 0.4(Aug 12, 2021)

    This release is for migration from Docker Hub registry to Github registry.

    • Add to the Github actions > Scan vulnerabilities with Trivy
    • Add to the Github actions > Build Docker image
    • Add Deepsource for code review
    • K8s manifest, Image runs as non-root uid 10001 and gid 10001.
    • K8s manifest, create namespace another
    Source code(tar.gz)
    Source code(zip)
  • 0.3(Jul 12, 2021)

    • Project rename to Another Autoscaler.
    • Environment variable (CHECK_EVERY) to configure the number of seconds of each run; By default is 5 seconds.
    • Update ClusterRoleBinding API version to rbac.authorization.k8s.io/v1 on K8s manifest.
    • Refactor of the class AAutoscaler to improve readability.
    Source code(tar.gz)
    Source code(zip)
Owner
Diego Najar
Diego Najar
GitHub Actions Poll Mode AutoScaler (GAPMAS)

GitHub Actions Poll Mode AutoScaler, or GAPMAS, is a simple tool that helps you run ephemeral GitHub Actions self-hosted runners on your own infrastructure.

Frode Nordahl 4 Nov 4, 2022
A python bot that stops muck chains

muck-chains-stopper-bot a bot that stops muck chains this is the source code of u/DaniDevChainBreaker (the main r/DaniDev muck chains breaker) guys th

null 24 Jan 4, 2023
GitGram Bot. Bot Then Message You Your Repo Starts, Forks, And Many More

Yet Another GitAlertBot Inspired From Dev-v2's GitGram Run Bot: Local Host Git Clone Repo : For Telethon Version : git clone https://github.com/TeamAl

Alina RoBot 2 Nov 24, 2021
This bot will automatically like and follow users that post under a specified hashtag

Instagram-bot This bot will automatically like and follow users that post under a specified hashtag Dependencies Java JDK Selenium Updated version of

Makana Edwards 1 Nov 4, 2021
Automatically commits and pushes changes from a specified directory to remote repository

autopush a simple python program that checks a directory for updates and automatically commits any updated files (and optionally pushes them) installa

carreb 1 Jan 16, 2022
📖 GitHub action schedular (cron) that posts a Hadith every hour on Twitter & Facebook.

Hadith Every Hour ?? A bot that posts a Hadith every hour on Twitter & Facebook (Every 3 hours for now to avoid spamming) Follow on Twitter @HadithEve

Ananto 13 Dec 14, 2022
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Arvinth Krishna 12 Aug 31, 2022
Davide Gallitelli 3 Dec 21, 2021
Joins a specified server on all the tokens

Joins a specified server on all the tokens. Usage python -m pip install requests python joiner.py Note Your tokens must be located in a text file call

null 1 Dec 21, 2021