Skip to content

Commit 1e85065

Browse files
authored
Alias for context
1 parent 9c83678 commit 1e85065

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

content/en/docs/reference/kubectl/cheatsheet.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ kubectl config set-context gce --user=cluster-admin --namespace=foo \
7474

7575
kubectl config unset users.foo # delete user foo
7676

77-
# short alias to set/show namespace (useful for CKAD/CKA exams)
78-
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace ; } ; f'
77+
# short alias to set/show context/namespace (useful for CKAD/CKA exams)
78+
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace | cut -d" " -f6 ; } ; f'
79+
alias kx='f() { [ "$1" ] && kubectl config use-context $1 || kubectl config current-context ; } ; f'
7980
```
8081

8182
## Kubectl apply

0 commit comments

Comments
 (0)