Skip to content

Go application that scales annotated Kubernetes deployments on a schedule.

License

Notifications You must be signed in to change notification settings

harryleesan/kubernetes-pod-scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This Go application checks all Kubernetes Deployments in all namespaces for scaling annotations and scales the deployment according to the annotations.

There are two branches in this repo:

  • master branch uses your own kubeconfig to access the cluster. This can be run in Docker on your local machine.
  • master-incluster branch is meant to be deployed in your Kubernetes cluster to be run as a Job/CronJob. This makes use of service account tokens to give your pod access to the cluster.

Usage

In the Kubernetes Deployment manifest of the Deployment that you want to enable scaling, add the annotations scaleUp and scaleDown.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app
  annotations: #used to attach data
    scaleDown: '0'
    scaleUp: '1'
spec:
  replicas: 1
  revisionHistoryLimit: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 2
  template:
    metadata:
      labels:
        app: app
    spec:
    ...

To run this application in a Docker container:

docker build -t halosan/k8-pod-scheduler:latest .
docker run -v $HOME/.kube:/root/.kube -e "SCALE=scaleUp" halosan/k8-pod-scheduler:latest 

The environment variable SCALE can either be scaleUp or scaleDown.

Development

Development through Docker

docker build -t halosan/k8-pod-scheduler:dev -f Dockerfile-dev .
docker run --rm -it -v $(pwd):/go/src/app \
  -v $HOME/.kube:/home/1000/.kube \
  halosan/k8-pod-scheduler:dev bash

Install dependencies

From the root directory of this project:

glide install

This will create a vendor directory which has the correct version of Kubernetes client-go.

About

Go application that scales annotated Kubernetes deployments on a schedule.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages