This project contains a Python script to rotate CAST AI managed nodes in a Kubernetes cluster. The script is responsible for cordoning, draining, and deleting nodes. It includes safeguards to ensure services are not disrupted, particularly when all replicas of a controller are on a single node.
(Current)
- Cordon nodes to prevent new pods from being scheduled.
- Check if all replicas of any controller reside on a single node.
- Evict one replica to another node if necessary, ensuring it becomes healthy and serves traffic.
- Drain nodes by safely evicting all remaining pods.
(Next):
- Log movements in Kubernetes events.
- Package the script using Docker and deploy as a Kubernetes CronJob.
- Create e2e tests to ensure the script works as expected.
- Python 3.9 or higher
- Docker
- Kubernetes cluster
- kubectl configured to interact with your Kubernetes cluster
-
Clone the Repository:
git clone https://github.com/your-organization/your-repo.git cd your-repo
-
Set Up a Virtual Environment:
python3 -m venv venv
source venv/bin/activate
- Install Dependencies:
pip install -r requirements.txt