当前位置: 首页 > 工具软件 > kubectx > 使用案例 >

kubectx

宦瀚
2023-12-01

介绍

kubectx is a tool to switch between contexts (clusters) on kubectl faster.
kubens is a tool to switch between Kubernetes namespaces (and configure them for kubectl) easily.
源码

使用

# switch to anoter cluster that's in kubeconfig
$ kubectx minikube
Switched to context "minikube".
 
# switch back to previous cluster
$ kubectx -
Switched to context "oregon".
 
# create an alias for the context
$ kubectx dublin=gke_ahmetb_europe-west1-b_dublin
Context "dublin" set.
Aliased "gke_ahmetb_europe-west1-b_dublin" as "dublin".
 
# change the active namespace on kubectl
$ kubens kube-system
Context "test" set.
Active namespace is "kube-system".
 
# go back to the previous namespace
$ kubens -
Context "test" set.
Active namespace is "default".

If you have fzf installed, you can also interactively select a context or cluster, or fuzzy-search by typing a few characters. To learn more, read interactive mode →

Both kubectx and kubens support Tab completion on bash/zsh/fish shells to help with long context names. You don’t have to remember full context names anymore.

安装

  1. Kubectl Plugins (macOS and Linux)
kubectl krew install ctx
kubectl krew install ns
  1. Homebrew (macOS and Linux)
brew install kubectx
  1. apt (Debian)
sudo apt install kubectx
  1. Manual Installation (macOS and Linux)
sudo git clone https://github.com/ahmetb/kubectx /opt/kubectx
sudo ln -s /opt/kubectx/kubectx /usr/local/bin/kubectx
sudo ln -s /opt/kubectx/kubens /usr/local/bin/kubens
 类似资料:

相关阅读

相关文章

相关问答