[k8s] kind๋ก Kubernetes ์ค์ต ํ๊ฒฝ ๊ตฌ์ฑํ๊ธฐ
Kind๋?
Kind๋ ๋ก์ปฌ ์ปดํจํฐ ํ๊ฒฝ์ ์ฟ ๋ฒ๋คํฐ์ค ํด๋ฌ์คํฐ๋ฅผ ์์ฝ๊ณ ๋น ๋ฅด๊ฒ ์ค์นํ๊ธฐ ์ํด ๋ง๋ค์ด์ง ๋๊ตฌ์ ๋๋ค.
Kind๋ Go ์ธ์ด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ, Docker์ด๋ฏธ์ง๋ฅผ ๊ธฐ๋ฐ์ผ๋ก kubeadm์ ์ด์ฉํ์ฌ ํด๋ฌ์คํฐ๋ฅผ ๋ฐฐํฌํฉ๋๋ค.
์์ธํ ๋ด์ฉ์ ์ ์ด๋ฏธ์ง๋ฅผ ํตํด kind ๊ณต์ ํํ์ด์ง์์ ํ์ธํ์๋ฉด ๋ฉ๋๋ค.
Kind ์ค์นํ๊ธฐ
์ค์น ๊ฐ์ด๋ ์๋ณธ URL : https://kind.sigs.k8s.io/docs/user/quick-start/#installation
MacOS
brew install kind
Windows
choco install kind
Linux
curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.15.0/kind-windows-amd64
Move-Item .\kind-windows-amd64.exe c:\some-dir-in-your-PATH\kind.exe
Kind๋ก ํด๋ฌ์คํฐ ์์ฑ
ํด๋ฌ์คํฐ ์์ฑ
kind create cluster # Default cluster context ์ด๋ฆ์ 'kind' ๋ก ์์ฑ
kind create cluster --name lucy # cluster context ์ด๋ฆ์ 'lucy' ๋ก ์ง์
ํด๋ฌ์คํฐ ์์ฑ ํ์ธ
kind get clusters
kubectl cluster-info --context lucy
ํด๋ฌ์คํฐ ์ญ์
kind delete cluster # ํด๋ฌ์คํฐ ํ ๊ฐ ์ญ์
kind delete clusters kind-local-cluster # ํด๋ฌ์คํฐ ํ๋ ์ด์ ์ญ์
์ค์ ํ์ผ์ ์ด์ฉํ Kind ํด๋ฌ์คํฐ ์์ฑ
ํด๋ฌ์คํฐ ์์ฑ
์ค์ ํ์ผ์ ์ด์ฉํ ํด๋ฌ์คํฐ ์์ฑ
์ค์ ํ์ผ์ ์ด์ฉํด์ kind ํด๋ฌ์คํฐ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
kind create cluster --config kind-example-config.yaml
3๊ฐ ๋ ธ๋ ํด๋ฌ์คํฐ ์์ฑ
3๊ฐ ๋ ธ๋(1 controller, 2worker) ํด๋ฌ์คํฐ ์ค์
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
6๊ฐ ๋ ธ๋ ํด๋ฌ์คํฐ ์์ฑ
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
์ฟ ๋ฒ๋คํฐ์ค ๋ฒ์ ์ค์
์ฟ ๋ฒ๋คํฐ์ค ๋ฒ์ ์ ๋ฐ๋ฅธ ์ด๋ฏธ์ง๋ https://github.com/kubernetes-sigs/kind/releases์์ ํ์ธ ๊ฐ๋ฅํฉ๋๋ค.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.16.4@sha256:b91a2c2317a000f3a783489dfb755064177dbc3a0b2f4147d50f04825d016f55
- role: worker
image: kindest/node:v1.16.4@sha256:b91a2c2317a000f3a783489dfb755064177dbc3a0b2f4147d50f04825d016f55
๋คํธ์ํฌ ์ค์
- Pod Subnet ์ค์
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
podSubnet: {IP ์ฃผ์}
๊ธฐ๋ณธ์ ์ผ๋ก IPv4 pod subnet์ผ๋ก "10.244.0.0/16"์ ์ฌ์ฉํฉ๋๋ค.
- Service Subnet ์ค์
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
serviceSubnet: {IP ์ฃผ์}
๊ธฐ๋ณธ์ ์ผ๋ก IPv4 pod subnet์ผ๋ก "10.96.0.0/16"์ ์ฌ์ฉํฉ๋๋ค.
- Default CNI ์ค์
Caliaco์ ๊ฐ์ 3rd party CNI ์ฌ์ฉ์ ์ํด์๋ default CNI ์ค์น๋ฅผ ํ์ง ๋ง์์ผ ํฉ๋๋ค..
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
# default CNI๊ฐ ์ค์น ๋์ง ์๋๋ค.
disableDefaultCNI: true
- kube-proxy ๋ชจ๋ ์ค์
iptables ๋๋ IPVS ์ค์ ์ ํํด์ ์ฌ์ฉ ๊ฐ๋ฅํ๊ณ default ๋ iptables์ ๋๋ค.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
kubeProxyMode: "ipvs"
์ต์ข ํด๋ฌ์คํฐ ์์ฑ
- ํด๋ฌ์คํฐ yaml ์์ฑ
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: cwave-cluster
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
image: kindest/node:{{์ฟ ๋ฒ๋คํฐ์ค ๋ฒ์ }}
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
- role: worker
image: kindest/node:{{์ฟ ๋ฒ๋คํฐ์ค ๋ฒ์ }}
- role: worker
image: kindest/node:{{์ฟ ๋ฒ๋คํฐ์ค ๋ฒ์ }}
networking:
serviceSubnet: {IP ์ฃผ์}
podSubnet: {IP ์ฃผ์}
- ํด๋ฌ์คํฐ ์์ฑ
# ์์ฑ
kind create cluster --config {yaml ํ์ผ}
# ์ญ์
kind delete cluster --name {ํด๋ฌ์คํฐ ์ด๋ฆ}
- ํด๋ฌ์คํฐ ์ ์ ์ ๋ณด ํ์ธ
kind get kubeconfig --internal --name {ํด๋ฌ์คํฐ ์ด๋ฆ}
ํด๋ฌ์คํฐ ์์ฑ ๊ฒฐ๊ณผ
$ kind create cluster --config .\set-cluster.yaml
Creating cluster "lab-cluster" ...
• Ensuring node image (kindest/node:v1.31.0) ๐ผ ...
โ Ensuring node image (kindest/node:v1.31.0) ๐ผ
• Preparing nodes ๐ฆ ๐ฆ ๐ฆ ๐ฆ ...
โ Preparing nodes ๐ฆ ๐ฆ ๐ฆ ๐ฆ
• Writing configuration ๐ ...
โ Writing configuration ๐
• Starting control-plane ๐น๏ธ ...
โ Starting control-plane ๐น๏ธ
• Installing CNI ๐ ...
โ Installing CNI ๐
• Installing StorageClass ๐พ ...
โ Installing StorageClass ๐พ
• Joining worker nodes ๐ ...
โ Joining worker nodes ๐
Set kubectl context to "kind-lab-cluster"
You can now use your cluster with:
kubectl cluster-info --context kind-lab-cluster
Have a nice day! ๐