카테고리 없음

KANS 3기 - KIND

시스템 엔지니어 2024. 9. 8. 00:09

KIND 실습

https://kind.sigs.k8s.io/

 

Docker in Docker로 쿠버네티스 클러스터 환경을 구성

 

 

클러스터 설치

root@kind:~# kind create cluster

 

Node 정보

Pod 정보

 

contol-plane 노드 1개만 존재 하는데, 배포가 될까요?

 

control-plane에 Taints 설정이 되지 않아 배포가 된다!

(⎈|kind-kind:N/A) root@kind:~# kubectl describe node | grep Taints
Taints:             <none>

 

 

 

워커노드를 추가해서 다시 생성

 

cat << EOT > kind-2node.yaml 
# two node (one workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
EOT
kind create cluster --config kind-2node.yaml --name myk8s

 

 

 

$ kind get nodes --name myk8s

 

 

 

어떻게 로컬에 접속 되는 걸까요?

$ kubectl cluster-info

 

$ docker ps

 

$ docker exec -it myk8s-control-plane ss -tnlp | grep 6443

 

 

Pod 생성 및 확인

cat <<EOF | kubectl create -f -
apiVersion: v1
kind: Pod
metadata:
  name: netpod
spec:
  containers:
  - name: netshoot-pod
    image: nicolaka/netshoot
    command: ["tail"]
    args: ["-f", "/dev/null"]
  terminationGracePeriodSeconds: 0
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx-pod
    image: nginx:alpine
  terminationGracePeriodSeconds: 0
EOF

 

 

 

 

포트 맵핑

cat <<EOT> kind-2node.yaml
# two node (one workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
  extraPortMappings:
  - containerPort: 30000
    hostPort: 30000
    listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0"
    protocol: tcp # Optional, defaults to tcp
  - containerPort: 30001
    hostPort: 30001
EOT

 

# kube-ops-view
# helm show values geek-cookbook/kube-ops-view
helm repo add geek-cookbook https://geek-cookbook.github.io/charts/
helm install kube-ops-view geek-cookbook/kube-ops-view --version 1.2.2 --set service.main.type=NodePort,service.main.ports.http.nodePort=30000 --set env.TZ="Asia/Seoul" --namespace kube-system

 

느낀점

KIND를 사용하여 쉽게 테스트 환경을 구성해 보고 서비스를 올려 보았다.
성능 테스트는 못하겠지만, 간단한 테스트들은 가능할 것 같다.
16GB 메모리 노트북으로 KIND를 설치해 보았는데, 메모리가 부족해서 동작하지는 않았다.
스펙 여유 있는 테스트 서버로 빠르게 테스트 해보면 좋을 것 같다.