(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ (
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-${OS}_${ARCH}.tar.gz" &&
tar zxvf krew-${OS}_${ARCH}.tar.gz &&
KREW=./krew-"${OS}_${ARCH}" &&
"$KREW" install krew
)
++ mktemp -d
+ cd /tmp/tmp.HzLPrar22Y
++ 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-linux_amd64.tar.gz
+ tar zxvf krew-linux_amd64.tar.gz
./._LICENSE
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.provenance'
./LICENSE
./._krew-linux_amd64
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.provenance'
./krew-linux_amd64
+ 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/.
| /
/
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.bashrc
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ source ~/.bashrc
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl krew version
OPTION VALUE
GitTag v0.4.5
GitCommit e7e5b61
IndexURI https://github.com/kubernetes-sigs/krew-index.git
BasePath /home/ssoon/.krew
IndexPath /home/ssoon/.krew/index/default
InstallPath /home/ssoon/.krew/store
BinPath /home/ssoon/.krew/bin
DetectedPlatform linux/amd64
kubectl 플러그인 관리자인 krew를 사용하여 쿠버네티스 리소스의 깔끔한 출력을 위한 neat과 여러 파드의 로그를 한 번에 볼 수 있는 stern 두 가지 플러그인을 설치
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl krew install neat stern
Updated the local copy of plugin index.
Installing plugin: neat
Installed plugin: neat
\
| Use this plugin:
| kubectl neat
| Documentation:
| https://github.com/itaysk/kubectl-neat
/
WARNING: You installed plugin "neat" from the krew-index plugin repository.
These plugins are not audited for security by the Krew maintainers.
Run them at your own risk.
Installing plugin: stern
Installed plugin: stern
\
| Use this plugin:
| kubectl stern
| Documentation:
| https://github.com/stern/stern
/
WARNING: You installed plugin "stern" from the krew-index plugin repository.
These plugins are not audited for security by the Krew maintainers.
Run them at your own risk.
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl neat version
kubectl-neat version: 2.0.4
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/istio-in-action/book-source-code-master$ kubectl stern --version
version: 1.32.0
commit: 5e06930fe21f951f079880ec2c13cd688aa5ca09
built at: 2025-01-21T01:17:09Z
✅ Kind 로 k8s 배포
ssoon@DESKTOP-UQRJB87:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ssoon@DESKTOP-UQRJB87:~$ mkdir ~/aews-labs
ssoon@DESKTOP-UQRJB87:~$ cd ~/aews-labs
KIND(Kubernetes IN Docker)를 사용하여 로컬에서 Kubernetes 클러스터를 생성
ssoon@DESKTOP-UQRJB87:~/aews-labs$ kind create cluster --name myk8s --image kindest/node:v1.32.2 --config - <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings: #호스트(로컬 머신)의 포트를 컨테이너 내부의 포트에 매핑하여 외부에서 접근할 수 있도록 설정
- containerPort: 30000
hostPort: 30000 #컨테이너의 30000번 포트를 호스트의 30000번 포트에 매핑
- containerPort: 30001
hostPort: 30001
- containerPort: 30002
hostPort: 30002
- containerPort: 30003
hostPort: 30003
kubeadmConfigPatches:#[KIND가 내부적으로 사용하는 kubeadm 설정을 수정(패치)하기 위한 섹션]
- | #YAML에서 여러 줄의 문자열을 정의할 때 사용
kind: ClusterConfiguration
controllerManager: #Kubernetes Controller Manager가 모든 네트워크 인터페이스(0.0.0.0)에서 요청을 수신하도록 설정
extraArgs:
bind-address: "0.0.0.0"
etcd: #etcd(데이터베이스)의 메트릭을 외부에서 수신할 수 있도록 0.0.0.0:2381에서 수신하도록 설정
local:
extraArgs:
listen-metrics-urls: "http://0.0.0.0:2381"
scheduler: #Kubernetes Scheduler도 모든 인터페이스에서 요청을 수신하도록 설정
extraArgs:
bind-address: "0.0.0.0"
- |
kind: KubeProxyConfiguration
metricsBindAddress: "0.0.0.0" #"0.0.0.0": Kube-Proxy의 메트릭을 모든 네트워크 인터페이스에서 수신하도록 설정
EOF
Creating cluster "myk8s" ...
✓ Ensuring node image (kindest/node:v1.32.2) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-myk8s"
You can now use your cluster with:
kubectl cluster-info --context kind-myk8s
Thanks for using kind! 😊
Kind 클러스터의 상태와 환경 설정
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/aews-labs$ kind get nodes --name myk8s
myk8s-control-plane
(⎈|kind-myk8s:N/A) ssoon@DESKTOP-UQRJB87:~/aews-labs$ kubens default
✔ Active namespace is "default"
(⎈|kind-myk8s:default) ssoon@DESKTOP-UQRJB87:~/aews-labs$ docker network ls
NETWORK ID NAME DRIVER SCOPE
0467263ae846 bridge bridge local
ad4e895cd1fa host host local
9e7b2ec4f002 kind bridge local
ae092270a351 none null local
docker inspect kind를 실행해 kind 클러스터의 네트워크 정보(이름: kind, IP: 172.18.0.2, 컨테이너: myk8s-control-plane)를 JSON 형식으로 보여주고, jq로 출력한 결과
(⎈|kind-myk8s:default) ssoon@DESKTOP-UQRJB87:~/aews-labs$ kubectl cluster-info;
Kubernetes control plane is running at https://127.0.0.1:38591
CoreDNS is running at https://127.0.0.1:38591/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
CRI 는 containerd 사용
(⎈|kind-myk8s:default) ssoon@DESKTOP-UQRJB87:~/aews-labs$ kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
myk8s-control-plane Ready control-plane 8m12s v1.32.2 172.18.0.2 <none> Debian GNU/Linux 12 (bookworm) 5.15.167.4-microsoft-standard-WSL2 containerd://2.0.3
kindnet-XXXX : Kind 클러스터의 기본 CNI (Container Network Interface) 플러그인
(⎈|kind-myk8s:default) ssoon@DESKTOP-UQRJB87:~/aews-labs$ kubectl get pod -A -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
...
kube-system kindnet-tx5s9 1/1 Running 0 8m16s 172.18.0.2 myk8s-control-plane <none> <none>
...
kind 클러스터의 네임스페이스 목록(default, kube-system 등)을 확인
(⎈|kind-myk8s:default) ssoon@DESKTOP-UQRJB87:~/aews-labs$ kubectl get namespaces
NAME STATUS AGE
default Active 9m32s
kube-node-lease Active 9m32s
kube-public Active 9m32s
kube-system Active 9m33s
local-path-storage Active 9m28s