snippets/old_snippets/watch-command.en.md

44 lines
1.1 KiB
Markdown

---
title: "watch command"
date: 2020-01-27T15:47:22+01:00
draft: false
snippet_types: ["watch"]
---
Currently at work we occasionally have to redeploy pods that have the same image tag but different
SHA hashes. The problem stems from the k8s deployments not picking up the changes and thus a
manually killing of the production pods is required. When they are restarted the SHA is checked and
new image pulled, during this process I like to watch along at the running pods to make sure things
are going smoothly.
I use to use the built in watch argument of k8s get pods command **-w**:
```shell
$ kubectl get pods -n shop -w
```
But this produces a really cluttered terminal output so I started just running the command on loop
```shell
$ while true; do; kubectl get pods -n shop ; sleep 5; done
```
Then a coworker showed me the watch command which has a much cleaner interface and outputs to a much
clearer less/more like non scrolling output.
```shell
$ watch -n 5 'kubectl get pods -n shop'
```
The watch command is availble via brew
```shell
$ brew install watch
```
source:
https://gitlab.com/procps-ng/procps/blob/master/watch.c