728x90
deployment, replicaset, pod
디플로이먼트 생성
- 디플로이먼트 생성
vagrant@kube-master1:~/test$ kubectl create deployment myapp --image=c1t1d0s7/myweb
- 리소스 확인 (디플로이먼트, 리플리카셋, 파드)
vagrant@kube-master1:~/test$ kubectl get deployments,replicasets,pods
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/myapp 1/1 1 1 18h
NAME DESIRED CURRENT READY AGE
replicaset.apps/myapp-79877ddf67 1 1 1 18h
NAME READY STATUS RESTARTS AGE
pod/myapp-79877ddf67-f9bp6 1/1 Running 1 18h
- 리소스의 자세한 정보 확인
vagrant@kube-master1:~/test$ kubectl get deployments,replicasets,pods -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/myapp 1/1 1 1 18h go-myweb ghcr.io/c1t1d0s7/go-myweb app=myapp
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
replicaset.apps/myapp-79877ddf67 1 1 1 18h go-myweb ghcr.io/c1t1d0s7/go-myweb app=myapp,pod-template-hash=79877ddf67
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/myapp-79877ddf67-f9bp6 1/1 Running 1 18h 10.233.101.21 kube-node1 <none> <none>
- 내부에서 접속 확인
vagrant@kube-master1:~/test$ curl 10.233.101.21:8080
Hello World!
myapp-79877ddf67-f9bp6
- 외부에서 접속 불가
vagrant@kube-master1:~/test$ curl 192.168.56.11
curl: (7) Failed to connect to 192.168.56.11 port 80: Connection refused
서비스 생성
- 서비스 생성
vagrant@kube-master1:~/test$ kubectl expose deployment myapp --port=80 --target-port=8080 --name=myapp-svc --type=LoadBalancer
- 생성된 서비스 확인
vagrant@kube-master1:~/test$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/myapp-79877ddf67-f9bp6 1/1 Running 1 18h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 19h
service/myapp-svc LoadBalancer 10.233.41.197 <pending> 80:30177/TCP 18h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/myapp 1/1 1 1 18h
NAME DESIRED CURRENT READY AGE
replicaset.apps/myapp-79877ddf67 1 1 1 18h
- 외부에서 접속 확인
vagrant@kube-master1:~/test$ curl 192.168.56.11:30177
Hello World!
myapp-79877ddf67-f9bp6
파드 스케일
- 파드 스케일
vagrant@kube-master1:~/test$ kubectl scale deployment myapp --replicas=3
deployment.apps/myapp scaled
- 파드 스케일 결과 확인
vagrant@kube-master1:~/test$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/myapp-79877ddf67-f9bp6 1/1 Running 1 18h
pod/myapp-79877ddf67-j2h64 1/1 Running 0 7s
pod/myapp-79877ddf67-v4q8j 1/1 Running 0 7s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 19h
service/myapp-svc LoadBalancer 10.233.41.197 <pending> 80:30177/TCP 18h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/myapp 3/3 3 3 18h
NAME DESIRED CURRENT READY AGE
replicaset.apps/myapp-79877ddf67 3 3 3 18h
- 파드가 삭제되어도 3개를 유지하기 위해서 바로 생성됨
vagrant@kube-master1:~/test$ kubectl delete pods myapp-79877ddf67-j2h64 &
[1] 23693
vagrant@kube-master1:~/test$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/myapp-79877ddf67-5kxt4 1/1 Running 0 6s
pod/myapp-79877ddf67-gqj59 1/1 Running 0 32s
pod/myapp-79877ddf67-j2h64 0/1 Terminating 0 3m3s
pod/myapp-79877ddf67-v4q8j 1/1 Running 0 3m3s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 19h
service/myapp-svc LoadBalancer 10.233.41.197 <pending> 80:30177/TCP 18h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/myapp 3/3 3 3 18h
NAME DESIRED CURRENT READY AGE
replicaset.apps/myapp-79877ddf67 3 3 3 18h
모든 리소스 삭제
- 디플로이먼트, 서비스 삭제
vagrant@kube-master1:~/test$ kubectl delete deployments.apps myapp
deployment.apps "myapp" deleted
vagrant@kube-master1:~/test$ kubectl delete service myapp-svc
service "myapp-svc" deleted
vagrant@kube-master1:~/test$ kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 19h
728x90
'쿠버네티스 교육 > 강의 내용 정리' 카테고리의 다른 글
220622_3_k8s_컨트롤러-ReplicaSet Controller (0) | 2022.06.22 |
---|---|
220622_2_k8s_파드의 생명 주기와 프로브-livenessProbe, startupProbe (0) | 2022.06.22 |
220621_3_k8s_네임스페이스_생성 및 삭제 (0) | 2022.06.21 |
220621_2_k8s_파드_레이블, 어노테이션 (0) | 2022.06.21 |
220621_1_k8s_파드_개념, 기본 템플릿 사용 (0) | 2022.06.21 |