はじめに
kubectlのプラグインを管理できるKrewについて紹介していきます。
Krewとは

Krewは、kubectlコマンドのプラグインマネージャーになります。
kubectlのプラグインの検索やインストール、アップデートが楽にできるようになります。
インストール
Krewをインストールします。
インストールするコマンドは下記の通りです。brewでもインストール可能ですが、公式ドキュメントによると今のところはサポートしていないということです。
1(
2 set -x; cd "$(mktemp -d)" &&
3 OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
4 ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
5 KREW="krew-${OS}_${ARCH}" &&
6 curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
7 tar zxvf "${KREW}.tar.gz" &&
8 ./"${KREW}" install krew
9)インストールが完了したら、下記を.bashrcや.zshrcなどに追記します。
1export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"使い方
簡単に使い方を紹介します。
プラグインリストの更新
1kubectl krew updateプラグインの検索
1kubectl krew search1❯ kubectl krew search
2NAME DESCRIPTION INSTALLED
3access-matrix Show an RBAC access matrix for server resources no
4accurate Manage Accurate, a multi-tenancy controller no
5advise-policy Suggests PodSecurityPolicies and OPA Policies f... no
6advise-psp Suggests PodSecurityPolicies for cluster. no
7allctx Run commands on contexts in your kubeconfig no
8apparmor-manager Manage AppArmor profiles for cluster. no
9applier Apply 'go text/template' files on k8s. no
10assert Assert Kubernetes resources no
11auth-proxy Authentication proxy to a pod or service no
12aws-auth Manage aws-auth ConfigMap no
13azad-proxy Generate and handle authentication for azad-kub... no
14bd-xray Run Black Duck Image Scans no
15blame Show who edited resource fields. no
16
17...プラグインのインストール
1kubectl krew install <plugin name>1❯ kubectl krew install resource-capacity
2Updated the local copy of plugin index.
3Installing plugin: resource-capacity
4Installed plugin: resource-capacity
5\
6 | Use this plugin:
7 | kubectl resource-capacity
8 | Documentation:
9 | https://github.com/robscott/kube-capacity
10/
11WARNING: You installed plugin "resource-capacity" from the krew-index plugin repository.
12 These plugins are not audited for security by the Krew maintainers.
13 Run them at your own risk.インストール済みのプラグインの更新
1kubectl krew upgradeインストール済みのプラグインリスト
1kubectl krew list1❯ kubectl krew list
2PLUGIN VERSION
3krew v0.4.3
4resource-capacity v0.7.0参考
Share
関連記事
【Tekton】Blue/Greenデプロイをやってみる
2022.09.30
CKAD受験体験記
2022.07.06
【Linkerd】実際に動かしてざっくり理解するLinkerd
2022.09.12
【kustomize】特定の環境だけbaseのリソースを削除する
2022.12.22




