Created
January 25, 2026 02:17
-
-
Save superbspeed/fa825d825450a3fce8a24c49d7110584 to your computer and use it in GitHub Desktop.
Aliases for kubectl commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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