This Python script monitors the status of pods in a Kubernetes namespace using kubectl
and displays them with color-coded statuses in the terminal using curses.
- Python 3.x
kubectl
configured and available in the system PATH- Terminal with color support (for proper display of color-coded statuses)
-
Clone the repository:
git clone https://github.com/aswinayyolath/pod_watch.git cd pod_watch
-
Install dependencies:
pip install kubernetes
Run the script with the following command:
python3 pod_watch.py -n <namespace> -t <refresh_time>
- : Specify the Kubernetes namespace to monitor.
- <refresh_time>: Refresh interval in seconds (default is 10 seconds).
Monitor pods in the myproject1 namespace with a refresh time of 5 seconds
python3 pod_watch.py -n myproject1 -t 5
- Green: Running and ready (all containers ready).
- Yellow: Pending, Unknown, ContainerCreating, PodInitializing, Init.
- Red: Failed, Terminating, CrashLoopBackOff, ErrImagePull, and other error states.