Skip to content

yrs147/depscaler-operator

Repository files navigation

Deployment Scaler Operator

The Deployment Scaler Operator is a Kubernetes controller designed to dynamically scale deployments based on predefined time periods.

Overview

This operator utilizes a custom resource named DepScaler to specify the scaling schedule for one or more deployments. It continuously monitors the current time and scales the specified deployments to the desired number of replicas if the current time falls within the specified time period (in hours).

Prerequisites

  1. Go version 1.20 (only required if running locally)
  2. A Running Kubernetes Cluster

Running on the cluster

  1. Build and push your image to the location specified by IMG:
make docker-build docker-push IMG=<some-registry>/depscaler:tag
  1. Deploy the controller to the cluster with the image specified by IMG:
make deploy IMG=<some-registry>/depscaler:tag
  1. Create a sample deployment
kubectl create deployment nginx --image=nginx
  1. Install Instances of Custom Resources:
kubectl apply -f config/samples/

Uninstall CRDs

To delete the CRDs from the cluster:

make uninstall

Undeploy controller

UnDeploy the controller from the cluster:

make undeploy

Running Locally against Cluster

  1. Clone the repository:

    git clone https://github.com/yrs147/deployment-scaler-operator.git
    cd deployment-scaler-operator
  2. Run the make install command

    make install
  3. Create a sample deployment

    kubectl create deployment nginx --image=nginx
  4. Now in another terminal window run the operator using

    make run
  5. Now create your custom Depscaler using the template below

    apiVersion: depscale.yrs.scaler/v1
    kind: DepScaler
    metadata:
      labels:
      name: depscaler-sample
    spec:
      begin: 10 # start time hour(in 24hr format)
      end: 17   # end time hour(in 24hr format)
      replicas: 6
      deployments:
        - name: nginx
          namespace: default
    

Testing the Controller

Use the make test command to run tests

make test

image

ScreenShots

Operator in action

image

image

To adjust the deployment scale for a particular time period, modify the begin and end hours in the spec section of the DepScaler manifest. Specify the desired number of replicas for that time period.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages