목차

00. 개요

What is Krew?

Krew는 kubectl 명령 줄 도구의 플러그인 관리자입니다.

Krew helps you:

  • kubectl 플러그인 발견,
  • 프러그인을 컴퓨터에 설치,
  • 설치된 플러그인을 최신 상태로 유지.

현재 Krew에 배포 된 '143 kubectl plugins'이 있습니다.

Krew는 macOS, Linux 및 Windows와 같은 모든 주요 플랫폼에서 작동합니다.

Krew는 kubectl 플러그인 개발자에게도 도움이됩니다. 플러그인을 여러 플랫폼에 쉽게 패키징하고 배포 할 수 있으며 Krew와 함께 중앙 집중식 플러그인 저장소를 통해 검색 할 수 있습니다.

01. krew Installation

01-01. 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

참고



  • No labels
Write a comment…