Skip to content

Instantly share code, notes, and snippets.

@superbspeed
Created January 25, 2026 02:17
Show Gist options
  • Select an option

  • Save superbspeed/fa825d825450a3fce8a24c49d7110584 to your computer and use it in GitHub Desktop.

Select an option

Save superbspeed/fa825d825450a3fce8a24c49d7110584 to your computer and use it in GitHub Desktop.
Aliases for kubectl commands
# Store these in your .bashrc or .zshrc
# Change kubectl namespace in current context
kns() {
if [ -z "$1" ]; then
echo "Current namespace: $(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null || echo 'default')"
echo "Usage: kns <namespace>"
echo "Available namespaces:"
kubectl get namespaces --output=name | sed 's/namespace\///'
return 1
fi
kubectl config set-context --current --namespace="$1"
echo "Switched to namespace: $1"
}
# kubectl short commands
alias k="kubectl"
alias kg="kubectl get"
alias kd="kubectl describe"
alias krm="kubectl delete"
alias klo="kubectl logs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment