Skip to content

Commit dfa6e8a

Browse files
authored
Merge pull request #30740 from mtilson/patch-1
short alias to set/show namespace
2 parents 9f6eb38 + 071d27e commit dfa6e8a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ 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 context/namespace (only works for bash and bash-compatible shells, current context to be set before using kn to set namespace)
78+
alias kx='f() { [ "$1" ] && kubectl config use-context $1 || kubectl config current-context ; } ; f'
79+
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace | cut -d" " -f6 ; } ; f'
7680
```
7781

7882
## Kubectl apply

0 commit comments

Comments
 (0)