Tools that make my life easier to work with kubernetes

I work on kubernetes a lot and here are list of tools that makes my life easier to build and manage.

kubetail nginx
# filter by containers with in pods 
kubetail l5d -c l5d
kubernetes context
  • Pimp my context — I work with multiple k8s environments, I would have to know which one I am working with and someone had tweeted this script. I have it in my .oh-my-zsh/themes/agnoster.zsh-theme . This context shows the k8s context and the current namespace.
prompt_kubecontext() {
prompt_segment white black "k8s-`kubectl config current-context`/`kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}'`"
## Main prompt
build_prompt() {

PROMPT='%{%f%b%k%}$(build_prompt) '
  • Manage Secrets — This is a handy tool to manage secrets in k8s , it always handy to decode secrets instead of doing bunch jq or jsonpath .
  • Port Forwarding — Some of the services/pods are internal and aren’t available via LB and I can’t really remember the kubectl port-forward command. So here is my script that makes port-forwarding easy.
#Port forward to linkerd
l5admin(){ kportforward l5d admin app=l5d 9000}
#clean up l5d admin port forwarding
l5clean(){lsof -t -i tcp:9000 | xargs kill}
#Port forward k8s
# $1 servicename
# $2 portname
# $3 pod selector
# $4 local port
kportforward() {
ADMINPORT=$(kubectl get svc $1 -o json |jq '.spec.ports[]| select(.name=="'$2'").port')
POD=$(kubectl get pods --selector $3 \
-o template --template '{{range .items}}{{}} {{.status.phase}}{{"\n"}}{{end}}' \
| grep Running | head -1 | cut -f1 -d' ')
kubectl port-forward $POD $4:$ADMINPORT &
sleep 2
open http://localhost:9000
  • kubectl hacks — Some of the kubectl hacks that makes life easier
#copy remote file locally
kubectl cp pod:/remote-file /local/file
#verbose kubectl
kubectl --v=8 version
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.