Useful Shorthands and Timesavers
alias k=’kubectl’
alias kga=’k get pods -A’
alias ktopmem=’k top pods --sort-by memory’
alias ktopcpu=’k top pods --sort-by cpu’

Fetch YAML
~$ k get deployments.apps flowerapi -o yaml

# To file
~$ k get deployments.apps nchat -o yaml > deployment.yaml

Generate YAML
~$ k create deployment frontend --image=nginx --dry-run=client --output=yaml

# To file
~$ k create deployment backend --image=mariadb --dry-run=client --output=yaml > backend.yaml

Context Switching - The Hard Way
~$ k config get-contexts

~$ k config use-context CONTEXT

KubeCTX by ahmetb
github.com/ahmetb/kubectx
~$ brew install kubectx

# Set default namespace for context
~$ kubens miniomatic

KubeColor by hidetatz
Kubectl in color
github.com/hidetatz/kubecolor
~$ brew install hidetatz/tap/kubecolor
~$ alias kubectl=’kubecolor’

Kubetail by johanhaleby
tail -f *.log for Kubernetes
github.com/johanhaleby/kubetail
~$ brew install johanhaleby/tap/kubetail

Neat
~$ kubectl krew install neat
github.com/itaysk/kubectl-neat
Remove clutter from Kubernetes manifests to make them more readable.

Ktop
~$ kubectl krew install ktop
github.com/vladimirvivien/ktop
Displays useful metrics information about nodes, pods, and other workload resources running in a Kubernetes cluster.

Kopilot
~$ kubectl krew install kopilot
github.com/knight42/kopilot
Your AI Kubernetes Expert
Uses GPT-3.5-turbo from OpenAI

Custom shorthand, “desc”
/usr/local/bin/kubectl-desc
Shorthand for “describe”
Simple shell script
Only append “kubectl-” to custom script

#!/bin/sh
exec kubectl describe $@