Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/satyamsundaram/k8s-deployment-scaler-cron
https://github.com/satyamsundaram/k8s-deployment-scaler-cron
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/satyamsundaram/k8s-deployment-scaler-cron
- Owner: satyamsundaram
- Created: 2023-08-13T17:04:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-13T17:07:24.000Z (over 1 year ago)
- Last Synced: 2024-04-09T14:50:33.850Z (9 months ago)
- Language: Python
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### About
- here we have a demo of an nginx deployment in a kubernetes cluster
- which is scaled up to 2 replicas at 10:30 AM daily (UTC) and scaled down to 1 replica at 11:30 AM daily (UTC)
- with the help of cronjobs which also run in the same cluster and same namespace as the deployment
- these cronjobs make use of the k8s service account to communicate with the k8s API and
- use a python script which is available as a docker image on docker.io as **satyamsundaram01/scaler_script** to scale deployments### How to run
- clone this repoTo use your own docker image, change the image name in the cronjob yaml files and build and push your image to docker.io:
```
cd scaler_script
docker build -t / .
docker login
docker push /
```Apply the yaml files in the following order:
```
# create nginx-deployment
kubectl apply -f nginx-deployment.yaml# create service account, role and role binding
kubectl apply -f serviceaccount.yaml
kubectl apply -f role.yaml
kubectl apply -f rolebinding.yaml# scale up cron job, triggers at 10:30 AM daily (UTC)
kubectl apply -f scaleupcron.yaml# scale down cron job, triggers at 11:30 AM daily (UTC)
kubectl apply -f scaledowncron.yaml(we can trigger the cron jobs manually to test them)
```And, there you have it, a deployment which scales up and down at a scheduled time daily.
You can modify this for your own use case.