Kubernetes1_2024_03_05

Kubernetes Architecture

쿠버네티스(kubernetes - k8s)

클러스터 - 마스터, 워커노드를 합한 노드의 집합

마스터 노드는 명령어를 날리는 곳

워커 노드는 실제 컨테이너가 떠있는 곳

 

클러스터 생성시 마스터는 자동 생성, 워커 노드는 추가해주어야 한다.

 


Kubernetes 실습

 

EKS에서 바로 실습을 하면 과금이 많이 나오기 때문에 play with Kubernetes 환경에서 연습

https://labs.play-with-k8s.com/

 

Play with Kubernetes

Play with Kubernetes is a labs site provided by Docker and created by Tutorius. Play with Kubernetes is a playground which allows users to run K8s clusters in a matter of seconds. It gives the experience of having a free Alpine Linux Virtual Machine in bro

labs.play-with-k8s.com

컴퓨터 세대 생성

1대는 마스터 노드, 2대는 워커 노드

복사 = 컨트롤 + 인서트 + c

붙혀넣기 = 컨트롤 시프트 + v

 

 

 1. Initializes cluster master node:
 kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr 10.5.0.0/16

 

1번 - Initializes cluster master node = 마스터 노드 생성

복사 및 붙혀넣기 후 실행

2. Initialize cluster networking:
 kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml

마스터 노드에 명령어 입력

 

1번. kubeadm join 로그 찍힌거 확인 및 내용 복사

 

워커노드로 설정할 컴퓨터1 에 kubeadm join 로그 붙혀넣기

 

워커노드로 설정할 컴퓨터2 에 kubeadm join 로그 붙혀넣기

 

마스터 노드에서 워커 노드들 연결 됐는지 확인

 


Pod

Pod = 논리적인 묶음

보통 하나의 Pod에 하나의 컨테이너를 넣는다. 한대 더 추가한다면 Container 정보와 관련된 정제 용도로 추가(Log용도)

 

kubectl get pods, kubectl get pods -A : 모든 네임스페이스에 있는 pod들 출력

 

kubectl get pods -A -o wide : 자세히 출력

 


명령어를 통한 Pod 생성 및 적용

마스터 노드에서 nginx를 실행 명령어

=>  특정 로직에 의해 마스터노드에 실행할 워커는

 

kubectl run nginx --image=nginx --port=80

kubectl get pods

nginx 동작 확인

 

 

마스터 노드에서 nginx를 실행 후 실행노드 확인

kubectl get pods -o wide : 더 자세히 보기

nginx가 node2에서 Running 되는지 확인

'Cloud > AWS' 카테고리의 다른 글

Kubernetes3_2024_03_06  (2) 2024.03.06
Kubernetes2_2024_03_06  (0) 2024.03.06
Docker3_2024_03_05  (0) 2024.03.05
Docker2_2024_03_04  (1) 2024.03.05
AWS 배포4_Git action_2024-02-28  (0) 2024.03.05