
master node 1에서 작업을한다.
worker node 2,3 에서도 kubectl 명령이 되도록 하였으니 방법은 동일하다.
root@master1:~# kubectl get ns
NAME STATUS AGE
cattle-fleet-system Active 3d21h
cattle-impersonation-system Active 3d21h
cattle-system Active 3d21h
default Active 6d19h
kube-node-lease Active 6d19h
kube-public Active 6d19h
kube-system Active 6d19h
local Active 6d13h
worker2-dev Active 5d22h
worker3-test Active 5d22h
root@master1:~# kubectl config view --minify | grep namespace:
namespace: default
root@master1:~#
root@master1:~# vi .profile
중략
...
# change namespace
kn() {
case $1 in
"dev")
kubectl config set-context --current --namespace=worker2-dev;;
"test")
kubectl config set-context --current --namespace=worker3-test;;
"current")
kubectl config view --minify | grep namespace;;
*)
kubectl config view --minify | grep namespace;;
esac
}
~
~
~
".profile" 35 lines, 948 characters written
root@master1:~#
root@master1:~# kn
namespace: worker3-test
root@master1:~# kn dev
Context "default" modified.
root@master1:~# kn
namespace: worker2-dev
root@master1:~#
주로 사용하는 리눅스 계정에도 동일하게 적용한다.
worker2,3 에도 동일하게 적용한다.