calculate the number of required nodes when moving a microservice to another node group in Kubernetes
Here’s a Python script to calculate the number of required nodes when moving a microservice to another node group in Kubernetes.
Script: calculate_nodes.py
How to Use?
- Save this script as
calculate_nodes.py
- Run the script in a terminal:
- Output Example (for 10 pods, 0.5 CPU & 1GiB per pod):
Key Features
✅ Handles both CPU and memory constraints
✅ Considers Kubernetes node allocatable resources (default 90%)
✅ Rounds up to ensure sufficient resources
✅ Easily customizable for different workloads
Key Considerations
- If the node auto-scaler is enabled, nodes will scale dynamically.
- Affinity/Anti-affinity rules may affect pod distribution.
- If using vertical pod autoscaler (VPA), pod resource requests can change dynamically.
- Overhead from networking, daemon sets, or system pods can affect node availability.
No comments