반응형
Notice
Recent Posts
Recent Comments

05-02 03:59
관리 메뉴

SaevOps

[쿠버네티스] 구성 요소의 기능 검증 본문

클라우드/Kubernetes

[쿠버네티스] 구성 요소의 기능 검증

세브웁스 2022. 9. 16. 17:41
반응형
[컨테이너 인프라 환경 구축을 위한 쿠버네티스/도커] 책 실습

 

! 사전작업

https://shyen.tistory.com/entry/%EC%BF%A0%EB%B2%84%EB%84%A4%ED%8B%B0%EC%8A%A4%EB%8F%84%EC%BB%A4-Vagrant-%EC%84%A4%EC%B9%98-%EC%A0%91%EC%86%8D-%ED%85%8C%EC%8A%A4%ED%8A%B8-1

 

[쿠버네티스/도커] Vagrant 설치 / 접속 / 테스트

[컨테이너 인프라 환경 구축을 위한 쿠버네티스/도커] 책 실습 0. Virtual Box 설치 1. Vagrant 설치 후 초기화 # 폴더로 이동 cd C:\HashiCorp # 베어그란트 초기화 vagrant init 2. 베이그란트 클라우드에서 이..

shyen.tistory.com


Kubectl

- 어느곳에서 존재해도 되며, 쿠버네티스 클러스터에 명령을 내릴 수 있음.

 

1. [w3-k8s]  쿠버네티스의 클러스터 정보를 마스터 노드에서 워커 노드로 가져오기

[root@w3-k8s ~]scp root@192.168.1.10:/etc/kubernetes/admin.conf .

2. 쿠버네티스의 노드들에 대한 정보 출력

[root@w3-k8s ~]kubectl get nodes
# 비밀번호 : vagrant

3. 쿠버네티스 클러스터 정보를 입력받는 옵션(--kubeconfig)과 마스터 노드에서 받아온 admin과 실행

[root@w3-k8s ~]kubectl get nodes --kubeconfig admin.conf
# 결과
NAME     STATUS     ROLES    AGE     VERSION
m-k8s    Ready      master   3h55m   v1.18.4
w1-k8s   Ready      <none>   3h51m   v1.18.4
w2-k8s   NotReady   <none>   3h47m   v1.18.4
w3-k8s   Ready      <none>   3h43m   v1.18.4

kubelet

- 쿠버네티스에서 파드의 생성과 상태 관리 및 복구 등을 구성하는 중요한 구성 요소

- kubelet에 문제 생기면 파드가 정상적으로 관리되지 않음

1. nginx-pod 생성하기

[root@m-k8s ~] kubectl create -f ~/_Book_k8sInfra/ch3/3.1.6/nginx-pod.yaml

# 결과
pod/nginx-pod created

2. 정상적으로 배포된 상태인지 확인 (STATUS 확인)

[root@m-k8s ~]# kubectl get pod

# 결과
NAME        READY   STATUS    RESTARTS   AGE
nginx-pod   1/1     Running   0          36m

3. 파드가 배포된 워커 노드 확인

o : 특정 형식의 출력 정보

wide : 더 많은 출력 정보

[root@m-k8s ~]kubectl get pods -o wide

#결과
NAME        READY   STATUS    RESTARTS   AGE   IP             NODE     NOMINATED NODE   READINESS GATES
nginx-pod   1/1     Running   0          44m   172.16.132.2   w3-k8s   <none>           <none>

kube-proxy

- 파드의 통신을 담당

 

1. 새로운 pod 생성

[root@m-k8s ~] kubectl create -f ~/_Book_k8sInfra/ch3/3.1.6/nginx-pod.yaml

# 결과
pod/nginx-pod created

2. 파드의 IP와 워커 노드 확인

[root@m-k8s ~]#  kubectl get pod -o wide

# 결과
NAME        READY   STATUS    RESTARTS   AGE   IP               NODE     NOMINATED NODE   READINESS GATES
nginx-pod   1/1     Running   0          25s   172.16.221.129   w1-k8s   <none>           <none>

3. 정상적으로 nginx가 작동하는지 확인

[root@m-k8s ~] curl 172.16.221.129
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

장애 상황 발생

1. w1 워커 문제 만들기

# 1번노드 문제 만들기.
[root@w1-k8s ~]# modprobe -r br_netfilter
[root@w1-k8s ~]# systemctl restart network

# 마스터에서 홈페이지 접속시도
[root@m-k8s ~]# curl 172.16.221.129
^c

2. 파드 상태 확인

[root@m-k8s ~]#  kubectl get pod -o wide
NAME        READY   STATUS    RESTARTS   AGE    IP               NODE     NOMINATED NODE   READINESS GATES
nginx-pod   1/1     Running   0          135m   172.16.221.129   w1-k8s   <none>           <none>

문제가 없어 보이지만 문제가 생긴 상황

 

3. 1번 워커 네트워크 정상화

[root@w1-k8s ~]modprobe br_netfilter
[root@w1-k8s ~]reboot

4. pod 상태 확인

[root@m-k8s ~]#  kubectl get pod -o wide
NAME        READY   STATUS    RESTARTS   AGE    IP               NODE     NOMINATED NODE   READINESS GATES
nginx-pod   1/1     Running   1          137m   172.16.221.130   w1-k8s   <none>           <none>

- restarts가 1로 변경된 것을 확인

 

5. 정상적으로 다시 올라온 것을 확인

[root@m-k8s ~]# curl 172.16.221.130
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

6. 파드 초기화 ( 삭제 )

[root@m-k8s ~]# kubectl delete -f ~/_Book_k8sInfra/ch3/3.1.6/nginx-pod.yaml

#결과
pod "nginx-pod" deleted

쿠버네티스 자료를 이용하여 어떤 일을 할 수 있는지 실습해보았다.

다음 기록엔 기본 사용법부터 시작할 예정이다

반응형
Comments