- control-plane: 일종의 '리모컨 역할'
예) master 컨테이너에서 node1,2,3에게 이것저것 명령할 때..
===================================
* 쿠버네티스 >> 도커 허브 로그인을 위한 secret 생성
config map 방식: 평문 저장
secret 방식: base64로 인코딩, 노출되지 않는다.
===================================
kubectl get nodes -o wide
kubectl get pods -o wide
>> container들이 각각 node1, node2, node3에 설치되어 있음.
===================================
오전 10:45 2024-11-02
* kubectl 명령 사용법
** master에는 node 안 생김
** kubectl describe nodes master
[root@master ~]# kubectl describe nodes master | grep Roles
Roles: control-plane
>> Labels 보단 Annotation이 주석에 좀 더 가깝다.
* kubectl get pods -o wide --watch
>> 파드의 정보를 "실시간"으로 확인
* kubectl run webserver1 --image=nginx --port 80
>> webserver1이라는 파드 생성
>> master가 node1,2,3 상황을 보고 최적의 node에 파드를 생성.
>> docker 방식으로는?
docker container run --name webserver1 -p 80:80 nginx
===================================
오전 11:14 2024-11-02
[root@master ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
webserver1 1/1 Running 0 4m6s 10.233.75.2 node2 <none> <none>
>> (중요) 여기서 ip는 파드의 ip를 이용.
파드안에 들어있는 여러 컨테이너의 접속을 위해 포트를 개별 명시. (ip는 다 똑같이 있음)
(docker에서는 컨테이너별로 ip가 할당되었었음 - ip가 다 다르다.)
===================================
오전 11:24 2024-11-02
kubectl create deploy webserver2 --image=httpd --replicas=3
>> pods를 3개로 생성
===================================
오전 11:25 2024-11-02
[root@master ~]# kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
webserver2 3/3 3 3 42s
===================================
오전 11:30 2024-11-02
[root@master ~]# kubectl get pod webserver1 -o yaml
[root@master ~]# kubectl get pod webserver1 -o json
===================================
오전 11:32 2024-11-02
Usage:
kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...] [options]
[root@master ~]# kubectl exec webserver1 -it -- /bin/bash
root@webserver1:/# cd /usr/share/nginx/html
root@webserver1:/usr/share/nginx/html# ls
50x.html index.html
===================================
[root@master ~]# kubectl logs webserver1 -f
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
===================================
[root@master ~]# kubectl port-forward webserver1 8080:80 &
[1] 198846
[root@master ~]# Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
>> docker container run --name webserver1 -p 8080:80 nginx
===================================
kubectl edit deploy webserver2
>> replicas 개수 변경
===================================
kubectl run webserver1 --image=nginx --port=80 --dry-run
>> --dry-run : 실행에 대한 결과만 추출 (실제 실행은 안 함)
===================================
kubectl create -f webserver3.yml
===================================
오전 11:56 2024-11-02
[root@master ~/kube/04]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
webserver1 1/1 Running 0 48m 10.233.75.2 node2 <none> <none>
webserver2-78d9985fc6-5dgwg 1/1 Running 0 31m 10.233.102.131 node1 <none> <none>
webserver2-78d9985fc6-b4dhh 1/1 Running 0 31m 10.233.75.3 node2 <none> <none>
webserver2-78d9985fc6-jffrb 1/1 Running 0 31m 10.233.71.3 node3 <none> <none>
webserver2-78d9985fc6-jlgd7 1/1 Running 0 11m 10.233.102.132 node1 <none> <none>
webserver2-78d9985fc6-knvhw 1/1 Running 0 11m 10.233.71.4 node3 <none> <none>
webserver3 1/1 Running 0 37s 10.233.75.4 node2 <none> <none>
[root@master ~/kube/04]# curl 10.233.75.4
<!DOCTYPE html>
===================================
오전 11:57 2024-11-02
[root@master ~/kube/04]# kubectl delete deploy webserver2
deployment.apps "webserver2" deleted
[root@master ~/kube/04]# kubectl delete pods --all
pod "webserver1" deleted
pod "webserver3" deleted
===================================
오후 1:01 2024-11-02
kubectl run myweb1 --image=httpd --port=80
kubectl describe pod myweb1
..
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 39s default-scheduler Successfully assigned default/myweb1 to node2
Normal Pulling 35s kubelet Pulling image "httpd"
Normal Pulled 29s kubelet Successfully pulled image "httpd" in 5.551037367s (5.55119887s including waiting)
Normal Created 29s kubelet Created container myweb1
Normal Started 28s kubelet Started container myweb1
..
==================================
'Kubernetes' 카테고리의 다른 글
[Kubernetes 수업] 07장 컨트롤러 (0) | 2024.11.03 |
---|---|
[kubernetes 수업] 06장 POD 관련 (0) | 2024.11.02 |
[kubernetes 수업] 05장 Architecture 관련 (0) | 2024.11.02 |