git clone https://github.com/ahmetb/kubectx
sudo cp kubectx/kube* /usr/local/bin/
kubectx
结果示例
context-cstkylegmzd
kubernetes-admin@kubernetes
kubectx kubernetes-admin@kubernetes
结果示例
Switched to context "kubernetes-admin@kubernetes".
查看cluster-info
kubectl cluster-info
结果示例
Kubernetes master is running at https://10.0.2.15:6443
KubeDNS is running at https://10.0.2.15:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
接下来,可以过以下命令在最近使用过的2个context快速切换。
kubectx -
kubens
结果示例(默认是default)
default
kube-public
kube-system
kubens kube-system
结果示例
Context "kubernetes-admin@kubernetes" modified.
Active namespace is "kube-system".
接下来,可以过以下命令在最近使用过的2个namespace快速切换。
kubens -