Script to continuously follow kubectl get pods

11/26/2018

I'm trying to build a script that can follow(-f) "kubectl get pods" see realtime update when I make any changes/delete pods on Ubuntu server. What could be the easiest/efficient way to do so ?

-- Swapnil Patel
kubectl
kubernetes
ubuntu

1 Answer

11/26/2018

You can just use

kubectl get pod <your pod name> -w

whenever any update/change/delete happen to the pod, you will see the update.

You can also use

watch -n 1 kubectl get  pod <your pod name>

This will continuously run kubectl get pod ... with 1 seconds interval. So, you will see latest sate.

-- Emruz Hossain
Source: StackOverflow