00. 개요
What is Krew?
Krew is the plugin manager for kubectl
command-line tool.
Krew helps you:
- discover kubectl plugins,
- install them on your machine,
- and keep the installed plugins up-to-date.
There are 143 kubectl plugins currently distributed on Krew.
Krew works across all major platforms, like macOS, Linux and Windows.
Krew also helps kubectl plugin developers: You can package and distribute your plugins on multiple platforms easily and makes them discoverable through a centralized plugin repository with Krew.
01. krew Installation
01-01. krew 설치
- https://krew.sigs.k8s.io/docs/user-guide/setup/install/
- Run this command to download and install
krew
설치 명령어 Set
( 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/')" && curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz" && tar zxvf krew.tar.gz && KREW=./krew-"${OS}_${ARCH}" && "$KREW" install krew )
설치 기록
sansae@win10pro-worksp:/workspaces$ 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/')" && > curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz" && > tar zxvf krew.tar.gz && REW=> KREW=./krew-"${OS}_${ARCH}" && > "$KREW" install krew ++ mktemp -d + cd /tmp/tmp.dz3ycln4i9 ++ uname ++ tr '[:upper:]' '[:lower:]' + OS=linux ++ uname -m ++ sed -e s/x86_64/amd64/ -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/' + ARCH=amd64 + curl -fsSLO https://github.com/kubernetes-sigs/krew/releases/latest/download/krew.tar.gz + tar zxvf krew.tar.gz ./LICENSE ./krew-darwin_amd64 ./krew-darwin_arm64 ./krew-linux_amd64 ./krew-linux_arm ./krew-linux_arm64 ./krew-windows_amd64.exe + KREW=./krew-linux_amd64 + ./krew-linux_amd64 install krew Adding "default" plugin index from https://github.com/kubernetes-sigs/krew-index.git. Updated the local copy of plugin index. Installing plugin: krew Installed plugin: krew \ | Use this plugin: | kubectl krew | Documentation: | https://krew.sigs.k8s.io/ | Caveats: | \ | | krew is now installed! To start using kubectl plugins, you need to add | | krew's installation directory to your PATH: | | | | * macOS/Linux: | | - Add the following to your ~/.bashrc or ~/.zshrc: | | export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" | | - Restart your shell. | | | | * Windows: Add %USERPROFILE%\.krew\bin to your PATH environment variable | | | | To list krew commands and to get help, run: | | $ kubectl krew | | For a full list of available plugins, run: | | $ kubectl krew search | | | | You can find documentation at | | https://krew.sigs.k8s.io/docs/user-guide/quickstart/. | / / sansae@win10pro-worksp:/tmp/tmp.dz3ycln4i9$ exit
01-02. krew 환경변수 설정 및 설치 확인
- vi ~/.bashrc 에 'PATH environment variable' 를 설정 합니다.
sansae@win10pro-worksp:/workspaces$ vi ~/.bashrc
- Shell 을 재 접속 합니다.
- kubectl krew 명령을 확인 합니다.
sansae@win10pro-worksp:/workspaces$ kubectl krew version OPTION VALUE GitTag v0.4.1 GitCommit ffa2933 IndexURI https://github.com/kubernetes-sigs/krew-index.git BasePath /home/sansae/.krew IndexPath /home/sansae/.krew/index/default InstallPath /home/sansae/.krew/store BinPath /home/sansae/.krew/bin DetectedPlatform linux/amd64
sansae@win10pro-worksp:/workspaces$ kubectl krew search NAME DESCRIPTION INSTALLED krew Package manager for kubectl plugins. yes [...]
02. krew-index 설치
sansae@win10pro-worksp:/workspaces$ kubectl krew index add kvaps https://github.com/kvaps/krew-index WARNING: You have added a new index from "https://github.com/kvaps/krew-index" The plugins in this index are not audited for security by the Krew maintainers. Install them at your own risk. sansae@win10pro-worksp:/workspaces$ kubectl krew install kvaps/node-shell Updated the local copy of plugin index. Updated the local copy of plugin index "kvaps". Installing plugin: node-shell Installed plugin: node-shell \ | Use this plugin: | kubectl node-shell | Documentation: | https://github.com/kvaps/kubectl-node-shell | Caveats: | \ | | You need to be allowed to start privileged pods in the cluster | / /
03. Node Shell 접속
sansae@win10pro-worksp:/workspaces$ kubectl get node NAME STATUS ROLES AGE VERSION aks-nodepool1-31236416-vmss000000 Ready agent 70d v1.18.14 sansae@win10pro-worksp:/workspaces$ sansae@win10pro-worksp:/workspaces$ kubectl node-shell aks-nodepool1-31236416-vmss000000 spawning "nsenter-fbbiu2" on "aks-nodepool1-31236416-vmss000000" If you don't see a command prompt, try pressing enter. root@aks-nodepool1-31236416-vmss000000:/# root@aks-nodepool1-31236416-vmss000000:/# date Wed Apr 7 10:10:51 UTC 2021 root@aks-nodepool1-31236416-vmss000000:/# exit logout pod "nsenter-fbbiu2" deleted
참고
참고