Sign inSign up

slic/kubectl-watch

By slic

Updated almost 3 years ago

A kubectl plugin to provide a pretty delta change view of being watched kubernetes resources.

Image
0

1.7K

slic/kubectl-watch repository overview

Quick reference

Getting started

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 $@

TUI keystroke help

KeystrokeDescription
char "j" or Down Arrow ↓go to next  resource
char "k" or Up Arrow ↑go to previous resource
Enter ↵Only show selected resource events
ESCgo back
PageUPscroll up diff content
PageDownscroll down diff content
Homereset scroll

Examples

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

Tag summary

Content type

Image

Digest

sha256:1520f3877

Size

33.7 MB

Last updated

about 3 years ago

docker pull slic/kubectl-watch