Skip to content

Commit 9c83678

Browse files
authored
short alias to set/show namespace
usage: $ kn # shows current namespace $ kn default # switch to specified namespace
1 parent acac224 commit 9c83678

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ kubectl config set-context gce --user=cluster-admin --namespace=foo \
7373
&& kubectl config use-context gce
7474

7575
kubectl config unset users.foo # delete user foo
76+
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'
7679
```
7780

7881
## Kubectl apply

0 commit comments

Comments
 (0)