前言
"kubectl-tree 是一款强大的 kubectl 插件,通过 ownerReferences 实现 Kubernetes 对象之间的所有权关系探索。相较于 kubectl lineage,它不仅更全面理解 API 对象的逻辑关系,而且无需依赖 ownerReferences。这使得揭示 Kubernetes 中对象间复杂的所有权结构变得更加简便,为用户提供更直观、全面的视角,助力更深入的集群管理与分析。"
Krew 目前支持macOS/Linux: bash/zsh[3], fish[4] 和**Windows[5]**
1.macOS/Linux环境( 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 )3.将$HOME/.krew/bin目录添加到你的 PATH 环境变量。为此,需要在你的.bashrc或者.zshrc文件并添加如下内容:
# vim ~/.bashrc 在文件末尾添加一下内容 export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"并重新启动你的shell。
$ kubectl krew krew is the kubectl plugin manager. You can invoke krew through kubectl: "kubectl krew [command]" Usage: kubectl krew [command] Available Commands: completion generate the autocompletion script for the specified shell 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 Flags: -h, --help help for krew -v, --v Level number for the log level verbosity Use "kubectl krew [command] --help" for more information about a command. Fish shell1.确保git已安装。
begin set -x; set temp_dir (mktemp -d); cd "$temp_dir" && set OS (uname | tr '[:upper:]' '[:lower:]') && set ARCH (uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/') && set 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 && set -e KREW temp_dir && cd - end3.将$HOME/.krew/bin目录添加到你的 PATH 环境变量。为此,为此,需要在你的config.fish文件并添加如下内容:
set -gx PATH $PATH $HOME/.krew/bin并重新启动你的shell。
kubectl krew install tree kubectl tree --help演示