A kubectl plugin to provide a pretty delta change view of being watched kubernetes resources.
1.7K
Copy paste following script to your $PATH folder, like /usr/local/bin/, and name it kubectl-watch. Then run chmod +x /path/to/kubectl-watch to make it executable.
#!/bin/bash
set -e
SUDO="sudo"
CMD_DOCKER=docker
CMD_NERDCTL=nerdctl
CMD=""
# IMG="ghcr.io/imuxin/kubectl-watch:latest"
IMG="docker.io/slic/kubectl-watch:latest" # docker hub image
KUBECONF="$HOME/.kube/config"
MOUNTKUBECONF="/root/.kube/config"
function cmd_exists() {
if ! command -v $1 &> /dev/null
then
return 1
fi
return 0
}
function kubectl_watch() {
if cmd_exists $CMD_DOCKER
then
CMD=$CMD_DOCKER
elif cmd_exists $CMD_NERDCTL
then
CMD=$CMD_NERDCTL
else
echo "container tool docker and nerdctl not found, please install one of them first."
exit -1
fi
$SUDO $CMD run -ti --rm -v $KUBECONF:$MOUNTKUBECONF $IMG $@
}
kubectl_watch $@
| Keystroke | Description |
|---|---|
| char "j" or Down Arrow ↓ | go to next resource |
| char "k" or Up Arrow ↑ | go to previous resource |
| Enter ↵ | Only show selected resource events |
| ESC | go back |
| PageUP | scroll up diff content |
| PageDown | scroll down diff content |
| Home | reset scroll |
watch deploy in all namespace
kubectl-watch deployment -A
watch deploy on some namespace
kubectl-watch deployment -n {namespace}
export watched resources into local storage, just add --export "/to/your/path"
kubectl-watch {resource} --export "/to/your/path"
managed-fields will be default excluded, add --include-managed-fields can show the managed fields changes.
kubectl-watch {resource} -include-managed-fields
Content type
Image
Digest
sha256:1520f3877…
Size
33.7 MB
Last updated
about 3 years ago
docker pull slic/kubectl-watch