5 kubectl Aliases That Save Me Hours Every Week

June 17, 2026

If you work with Kubernetes every day, you already know the pain.

You're debugging a production issue at 11pm, and you're typing kubectl get pods -n monitoring --field-selector=status.phase=Running for the fifth time. Your fingers are tired. Your patience is gone.

That's exactly when I sat down and finally set up proper aliases — and I haven't looked back since.

Here are the 5 that made the biggest difference.


How to Set Them Up

Add these to your ~/.zshrc or ~/.bashrc:

# then run:
source ~/.zshrc

That's it. No tools, no plugins, just shell aliases.


1. k — The Base Shortcut

alias k='kubectl'

Simple, but you'd be surprised how much this alone saves. Every command you run starts here. Shaving 6 characters off every single command adds up across a full day.

# Before
kubectl get nodes

# After
k get nodes

2. kgp / kgpa — Get Pods Fast

alias kgp='kubectl get pods'
alias kgpa='kubectl get pods -A'

Getting pod status is probably the most common thing I do. kgp lists pods in the current namespace, kgpa shows everything across all namespaces — useful when you're not sure which namespace a service landed in.

kgp                        # pods in current namespace
kgpa                       # pods across all namespaces
kgp -n production          # pods in a specific namespace
kgp -w                     # watch mode — live updates

3. kl — Stream Logs Without the Pain

alias kl='kubectl logs -f'

-f follows the log stream in real time. Without this alias, I was constantly mistyping kubectl logs without -f, getting a static dump, and having to rerun it. Now it's just kl <pod-name>.

kl my-api-pod-7d4b9c       # stream logs from a pod
kl my-api-pod-7d4b9c -c sidecar   # specific container in a pod
kl deployment/my-api       # logs from a deployment directly

4. kex — Exec Into a Pod in One Shot

alias kex='kubectl exec -it'

Exec-ing into a pod for debugging is something I do multiple times a day. The full command is kubectl exec -it <pod> -- /bin/bash (or /bin/sh on minimal images). The alias cuts out the repetitive part.

kex my-pod -- /bin/bash    # bash shell
kex my-pod -- /bin/sh      # sh for Alpine-based images
kex my-pod -- env          # just print env vars without a full shell

5. kctx / kns — Switch Context and Namespace Instantly

alias kctx='kubectl config use-context'
alias kns='kubectl config set-context --current --namespace'

This one is a game changer if you manage multiple clusters or environments. Switching context and namespace used to require me to look up the full context name every time.

kctx production-gke        # switch to production cluster
kctx staging-eks           # switch to staging cluster
kns monitoring             # set current namespace to monitoring
kns default                # back to default

All Together — Copy-Paste Ready

# ~/.zshrc or ~/.bashrc

# Base
alias k='kubectl'

# Get resources
alias kgp='kubectl get pods'
alias kgpa='kubectl get pods -A'

# Logs
alias kl='kubectl logs -f'

# Exec
alias kex='kubectl exec -it'

# Context & Namespace switching
alias kctx='kubectl config use-context'
alias kns='kubectl config set-context --current --namespace'

Bonus: Enable kubectl Autocompletion

While you're editing your .zshrc, add this too — it gives you tab completion for pod names, namespaces, and flags:

source <(kubectl completion zsh)
compdef k=kubectl   # make completion work with the 'k' alias too

Now typing k get pods -n <TAB> will autocomplete namespaces. Huge time saver.


These might look small individually, but the cumulative effect across a full week of Kubernetes work is significant. The goal isn't to be clever — it's to remove friction from the commands you run dozens of times a day so you can focus on the actual problem.

If you have aliases you swear by that I haven't listed, I'd love to hear them.