본문 바로가기

인프라/Kubernetes

Kind(Kubernetes in Docker)를 통한 kubernetes 실습 환경 구축

2023.08.27 - [인프라/Kubernetes] - Kubernetes 실습 및 서비스 구축

 

Kubernetes 실습 및 서비스 구축

예상 k8s 서비스 아키텍쳐 Kubernetes 란? 쿠버네티스는 컨테이너화된 서비스를 쉽고 빠르게 배포,확장,관리하기 자동화 해주는 오픈소스 플랫폼입니다. k8s 사용 이유 쿠퍼네티스는 분산 되어 있는

younyellow.tistory.com

윈도우 wsl2 ubuntu와 docker 연동

kind 설치

root@DESKTOP-Q4VBHGG:/home/yellownyou# curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.10.0/kind-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 7277k  100 7277k    0     0   433k      0  0:00:16  0:00:16 --:--:--  417k

전역에서 사용 할 수 있도록 위치를 이동

root@DESKTOP-Q4VBHGG:/home/yellownyou# mv ./kind /usr/local/bin/

vscode를 통한 wsl 원격 접속

하단 버튼을 클릭 후 ubuntu 고르

노드 설정 kind-node.yaml

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
  - role: worker
  - role: worker
  - role: worker

 

클러스터 생성

root@DESKTOP-Q4VBHGG:/home/yellownyou# kind create cluster --name kubernetes --config ./kind-node.yaml
Creating cluster "kubernetes" ...
 ✓ Ensuring node image (kindest/node:v1.20.2) 🖼
 ✓ Preparing nodes 📦 📦 📦 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
 ✓ Joining worker nodes 🚜
Set kubectl context to "kind-kubernetes"
You can now use your cluster with:

kubectl cluster-info --context kind-kubernetes

Not sure what to do next? 😅  Check out https://kind.sigs.k8s.io/docs/user/quick-start/

노드 생성 확인

root@DESKTOP-Q4VBHGG:/home/yellownyou# kubectl get nodes
NAME                       STATUS   ROLES                  AGE   VERSION
kubernetes-control-plane   Ready    control-plane,master   69s   v1.20.2
kubernetes-worker          Ready    <none>                 37s   v1.20.2
kubernetes-worker2         Ready    <none>                 38s   v1.20.2
kubernetes-worker3         Ready    <none>                 37s   v1.20.2
root@DESKTOP-Q4VBHGG:/home/yellownyou# docker container ls
CONTAINER ID   IMAGE                  COMMAND                  CREATED              STATUS              PORTS
            NAMES
113552c08f93   kindest/node:v1.20.2   "/usr/local/bin/entr…"   About a minute ago   Up About a minute   127.0.0.1:40385->6443/tcp   kubernetes-control-plane
e23dda72fb9e   kindest/node:v1.20.2   "/usr/local/bin/entr…"   About a minute ago   Up About a minute
            kubernetes-worker2
d18eb251cf54   kindest/node:v1.20.2   "/usr/local/bin/entr…"   About a minute ago   Up About a minute
            kubernetes-worker3
2ba3c582f28a   kindest/node:v1.20.2   "/usr/local/bin/entr…"   About a minute ago   Up About a minute
            kubernetes-worker

 

 

Kubernetes 관련 파일은 

https://github.com/Sihyun3/LearningKubernetes/tree/main

 

GitHub - Sihyun3/LearningKubernetes

Contribute to Sihyun3/LearningKubernetes development by creating an account on GitHub.

github.com

여기서 확인 가능합니다.