🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

github.com/west-coast-devops/scheduled-scaler

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/west-coast-devops/scheduled-scaler

v0.0.0-20240206195208-58780527dbab
Source
Go
Version published
Created
Source

Scheduled Scaler

All Contributors

Docker Image Version (latest semver) Travis (.com) branch

In order to use the ScheduledScaler you will need to install the CRD and deploy the Scaling Controller into your Kubernetes cluster.

Requirements

  • Kubernetes Version: 1.7+
  • Kubernetes Cluster Settings:
    • "Legacy authorization": "Enabled"

Tested Environments

  • Google Kubernetes Engine
    • Kubernetes Version: 1.9.3-gke.0, 1.7.15
    • Docker Version: 1.12.5
    • Golang Version: 1.9.4

Getting Started

Clone this repo

mkdir -p $GOPATH/src/k8s.restdev.com && \
git clone https://github.com/k8s-restdev/scheduled-scaler.git $GOPATH/src/k8s.restdev.com/operators && \
cd $GOPATH/src/k8s.restdev.com/operators

Install using Helm Chart

helm install scheduled-scaler artifacts/kubes/scaling/chart

Note: This uses the image stored at https://hub.docker.com/r/k8srestdev/scaling by default.

See chart README for detailed configuration options

Installation without Helm (and compiling binary yourself):

  • Install the CRD
kubectl create -f ./artifacts/kubes/scaling/crd.yml
  • Once you have the repo installed on your local dev you can test, build, push and deploy using make

Note: If you are just looking for a prebuilt image you can find the latest build here. Just add that image tag to the deployment yml in the artificats dir and apply to your kube-system namespace to get up and running without doing a fresh build :D

Using Make

The Makefile provides the following steps:

  • test - Run go unit tests
  • build - Build the go bin file and docker image locally
  • push - Push the built docker image to gcr (or another repository of your choice)
  • deploy - Deploy the updated image to your Kubernetes cluster

Each of these steps can be run in a single pass or can be used individually.

Examples

  • Do all the things (kubectl)
# This example will test, build, push and deploy using kubectl's currently configured cluster
make OPERATOR=scaling PROJECT_ID=my_project_id
  • Do all the things (kubernodes)
# This example will test, build, push and deploy using kubernodes
make OPERATOR=scaling PROJECT_ID=my_project_id DEPLOYBIN=kn KN_PROJECT_ID=my_kubernodes_project_id

Note: You only need to add KN_PROJECT_ID if it differs from PROJECT_ID

  • Just build the image
make build OPERATOR=scaling PROJECT_ID=my_project_id
  • Just push any image
make push IMAGE=myrepo/myimage:mytag
  • Just deploy any image (kubectl)
make deploy OPERATOR=scaling IMAGE=myrepo/myimage:mytag
  • Just deploy any image (kubernodes)
make deploy OPERATOR=scaling IMAGE=myrepo/myimage:mytag DEPLOYBIN=kn KN_PROJECT_ID=my_kubernodes_project_id

Now that you have all the resources required in your cluster you can begin creating ScheduledScalers.

Scheduled Scaler Spec

Note: This controller uses the following Cron Expression Format

HPA

apiVersion: "scaling.k8s.restdev.com/v1alpha1"
kind: ScheduledScaler
metadata:
  name: my-scheduled-scaler-1
spec:
  timeZone: America/Los_Angeles
  target:
    kind: HorizontalPodAutoscaler
    name: my-hpa
    apiVersion: autoscaling/v1
  steps:
  #run at 5:30am PST
  - runat: '0 30 5 * * *'
    mode: range
    minReplicas: 1
    maxReplicas: 5

Instance Group

apiVersion: "scaling.k8s.restdev.com/v1alpha1"
kind: ScheduledScaler
metadata:
  name: my-scheduled-scaler-2
spec:
  timeZone: America/Los_Angeles
  target:
    kind: InstanceGroup
    name: my-instance-group-name
    apiVersion: compute/v1
  steps:
  #run at 5:30am PST
  - runat: '0 30 5 * * *'
    mode: fixed
    replicas: 3

As you'll see above, you can target either instance groups (if you are on GKE) or hpa, but all the other options are the same.

Options

OptionDescriptionRequired
spec.timeZoneTimezone to run crons inFalse
spec.target.kindType of target (InstanceGroup/HorizontalPodAutoscaler)True
spec.target.nameName of the target resourceTrue
spec.target.apiVersionAPI Version of the targetTrue
spec.stepsList of stepsTrue
spec.steps[].runatCronjob time string (gocron)True
spec.steps[].modeType of scaling to run (fixed/range)True
spec.steps[].replicasDefined if mode is 'fixed'False
spec.steps[].minReplicasDefined if mode is 'range'False
spec.steps[].maxReplicasDefined if mode is 'range'False

For more details on how this add-on can be used please follow the link below: Learn More...

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Sheridan C Rawlins

🚧 ⚠️ 💻

vnandha

🐛 🚧

so0k

🚇 📖

Andreas Wunderlich

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

FAQs

Package last updated on 06 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts