/kss

Kubernetes pod status on steroid πŸ’‰

Primary LanguagePythonApache License 2.0Apache-2.0

KSS - Kubernetes pod status on steroid πŸ’‰

A simple tool to show the current status of a pod and its associated containers and initContainers.

This was developed out of frustration with kubectl get pod not showing much and kubectl describe pod showing way too much in a cryptic way. Debugging failed pods with a lot of initContainers and sideCars usually was done with kubectl get pod -o yaml |less wiht a lot of going up and down and a bunch of censored swearing πŸ”ž. All those techniques for introspection and debugging are still useful and KSS is not planning to fully replace them but now thanks to it I swear less and my sanity is back πŸ˜….

Usage

You can specify a pod or multiple ones as argument to KSS, if you don't it will launch fzf and let you choose the pod interactively, if there is only one pod available it will select it automatically. If you would like to choose multiple pods you can use the key [TAB] and select them, KSS would then show all of them.

KSS shows a preview when running with fzf, it will preview with itself if it can find itself in the PATH, if not it will fallback to a good ol' boring kubectl describe πŸ‘΄πŸΌπŸ‘΅πŸ».

If you add the -l option it will show you the output log of the container, you can adjust how many lines of the log you want to see if you add the flag --maxlines=INT.

You can use the -r option if you would like to restrict it to only some containers, it accepts a regexp as an argument, so you can do some fancy matching in there. You would typically use this flag combined when you are outputting the container's log (-l).

Install

You just make sure you have >=Python3.6, fzf and kubectl. You then can download the script and put it directly into your PATH or checkout this GIT repo and link the binary into your path so you can have do some git pull to get the updates.

With zsh you can install the _kss completionfile to your fpath.

I may do a krew plugin and/or brew homebrew repository if this get requested enough. Watch this space as cool people would say πŸ˜ŽπŸ„πŸ€™.

Screenshots

Success run

Success run

Failed run

Fail run

Failed run with logs

Fail run

Restrict the logs output only to a container and only to one line with the -r and --maxlength flags

Restrict to some pod

Selecting a pod with fzf

Select a pod with FZF

Misc

  • The code is getting quite tortured, like some sort of spaghetti plate 🍝 with greasy meatballs πŸ₯© on the top, the kind of stuff you start to write quickly and dirty out of frustration to fix a problem and it grows it grows until it really become an unreadable beast. I probably going to rewrite it up properly with tests and all (in a compiled language perhaps?) soonish enough. But hey who cares, since it kinda works! (until I broke it :D) πŸ˜