之前的文章用到一个安装命令
kubectl krew install ns
用到了krew来安装ns插件。
krew 是一个用来管理 kubectl 插件的工具,类似于 apt 或 yum,支持搜索、安装和管理kubectl 插件。
安装krew
安装命令:
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/(arm)(64)?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
生效
echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
验证安装成功
[root@paas-m-k8s-master-1 ~]# kubectl plugin list
The following compatible plugins are available:
/root/.krew/bin/kubectl-krew
krew命令
[root@paas-m-k8s-master-1 ~]# kubectl krew
krew is the kubectl plugin manager.
You can invoke krew through kubectl: "kubectl krew [command]..."
Usage:
kubectl krew [command]
Available Commands:
help Help about any command
index Manage custom plugin indexes
info Show information about an available plugin
install Install kubectl plugins
list List installed kubectl plugins
search Discover kubectl plugins
uninstall Uninstall plugins
update Update the local copy of the plugin index
upgrade Upgrade installed plugins to newer versions
version Show krew version and diagnostics
比较简单,命令参数不多。
搜素
image-20240311170020039
安装
kubectl krew install ns
查看安装
[root@paas-m-k8s-master-1 ~]# kubectl krew list
PLUGIN VERSION
krew v0.4.4
ns v0.9.5
使用
image-20240311170129602
卸载、升级不演示了
目前的插件列表
Kubectl plugins available · Krew (k8s.io)
不算太多,二百多个。
有一些还是挺方便的。
比如tail,可以用来方便的打印pod或者ns下的所有pod,或者deploymeng,sts等的日志
现在更推荐使用krew来安装和管理kubectl命令插件,而不是直接安装安装包。