I'm trying to build a script that can follow(-f) kubectl get pods
see a realtime update when I make any changes/delete pods on Ubuntu server.
What could be the easiest/efficient way to do so?
Thankfully, the kubectl command lets you look at deployments as well. The command takes a flag (-l / –selector) that lets you filter by label. Since we tag our deployment pods with the example label, we can see all of them. The -f / –follow flag then continuously prints out the message from those pods.
To check the version, enter kubectl version . In this exercise you will use kubectl to fetch all of the Pods running in a cluster, and format the output to pull out the list of Containers for each.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With