Skip to content

cloudsteak/scale-operator

Repository files navigation

scale-operator

Kubernetes time based scale operator

Commands

  1. Create project
kubebuilder init --domain scaler.cloudsteak.com --owner "CloudSteak" --repo github.com/cloudsteak/scale-operator.git
  1. Create API
kubebuilder create api --kind Scaler --version v1alpha1 --group api
  1. Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
make generate
  1. Create manifests (CRD, RBAC and Controller)
make manifests
  1. Develop your code

  2. Install CRDs

make install
  1. Create deployment
kubectl create deploy nginx --image=nginx
  1. Configure scaler
nano config/samples/api_v1alpha1_scaler.yaml
spec:
  start: 5 # UTC time
  end: 11 # UTC time
  replicas: 2
  deployments:
    - name: nginx
      namespace: nginx
  1. Create scaler
kubectl apply -f config/samples/api_v1alpha1_scaler.yaml
  1. Run the controller
make run
  1. Check output

** Scale up

2024-07-08T07:41:02+02:00       INFO    --- Scaling up deployments      {"controller": "scaler", "controllerGroup": "api.scaler.cloudsteak.com", "controllerKind": "Scaler", "Scaler": {"name":"scaler-sample","namespace":"default"}, "namespace": "default", "name": "scaler-sample", "reconcileID": "d113f2c7-e8d2-4d9a-a3f9-3b51134e7dd1"}
2024-07-08T07:41:02+02:00       INFO    Scaling Deployment      {"name": "nginx", "namespace": "default", "replicas_to": 2, "replicas_from": 1}

** Scale down

2024-07-08T16:40:02+02:00       INFO    --- Scaling down deployments    {"controller": "scaler", "controllerGroup": "api.scaler.cloudsteak.com", "controllerKind": "Scaler", "Scaler": {"name":"scaler-sample","namespace":"default"}, "namespace": "default", "name": "scaler-sample", "reconcileID": "c0668843-f7ee-4c7a-99d6-7cf6e5fbeb0f"}
2024-07-08T16:40:02+02:00       INFO    Scaling Deployment      {"name": "nginx", "namespace": "default", "replicas_to": 1, "replicas_from": 2}

About

Kubernetes time based scale operator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published