[k8s] kind로 쿠버네티스 설치하기 (1)

림예·2024년 7월 21일

k8s

목록 보기
2/5
post-thumbnail

1. What is Kind?

Kind 는 로컬 컴퓨터 환경에 쿠버네티스 클러스터를 손쉽고 빠르게 설치 하기 위해 만들어진 도구입니다.

Kind는 Go 언어를 기반으로 만들어 졌으며, Docker 이미지를 기반으로 kubeadm을 이용하여 클러스터를 배포 합니다.

kind 공식 홈페이지 : kind.sigs.k8s.io


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

Kubectx, Kubens 설치

choco install kubectx
choco install kubens

3. Kind 로 클러스터 생성

클러스터 생성

kind create cluster # Default cluster context 이름은 'kind' 로 생성
kind create cluster --name dangtong # cluster context 이름을 'dangtong' 으로 지정

클러스터 생성 확인

kind get clusters
kubectl cluster-info --context dangtong

클러스터 삭제

kind delete cluster

kind delete clusters kind-local-cluster

4. 설정 파일을 이용한 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: "10.244.0.0/16"
  • Service Subnet 설정
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
  serviceSubnet: "10.96.0.0/12"
  • 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:v1.29.4
  extraPortMappings:
    - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
- role: worker
  image: kindest/node:v1.29.4
- role: worker
  image: kindest/node:v1.29.4
networking:
  serviceSubnet: "10.120.0.0/16"
  podSubnet: "10.110.0.0/16"
  • 클러스터 생성
# 생성
kind create cluster  --config ./3-node-cluster.yaml

# 삭제
kind delete cluster --name cwave-cluster
  • 클러스터 접속 정보 확인
kind get kubeconfig --internal --name cwave-cluster




profile
Think big 🌏

0개의 댓글