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
~$ brew install kubectx

# Set default namespace for context
~$ kubens miniomatic

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

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

~$ kubectl krew install neat
Remove clutter from Kubernetes manifests to make them more readable.

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

~$ kubectl krew install kopilot
Your AI Kubernetes Expert
Uses GPT-3.5-turbo from OpenAI

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

exec kubectl describe $@