기본 nginx 서버 배포 - TheOpenCloudEngine/uEngine-cloud GitHub Wiki

기본 nginx 서버의 배포

1. 배포

 > kubectl run nginx --image=nginx
   # deployment.apps "nginx" created

2. 배포 확인

 > kubectl get deploy nginx
   # NAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
   # nginx     1         1         1            1           3m

 > kubectl get replicaset -l run=nginx
   # NAME               DESIRED   CURRENT   READY     AGE
   # nginx-65899c769f   1         1         1         4m

 > kubectl get po -l run=nginx 
   * "-l" 옵션은 label의 key/value 로 객체를 필터링함.
   # NAME                     READY     STATUS    RESTARTS   AGE
   # nginx-65899c769f-mccqx   1/1       Running   0          5m

3. 제거와 재생성

# pod 들의 제거
 > kubectl delete po --all

# pod 를 제거해도 재생됨을 확인
 > kubectl get po

4. Scale Out

pod를 3개로 증가시킴 (--replicas)
 > kubectl scale deploy nginx --replicas=3
 # deployment.extensions "nginx" scaled
 
 > kubectl get po
 # NAME                     READY     STATUS    RESTARTS   AGE
 # nginx-65899c769f-dtq68   1/1       Running   0          9s
 # nginx-65899c769f-g4w5z   1/1       Running   0          3m
 # nginx-65899c769f-xkprv   1/1       Running   0          9s

 > kubectl delete po --all   
 * pod 를 모두 지움
 # pod "nginx-65899c769f-dtq68" deleted
 # pod "nginx-65899c769f-g4w5z" deleted
 # pod "nginx-65899c769f-xkprv" deleted

 > kubectl get po
 # NAME                     READY     STATUS    RESTARTS   AGE
 # nginx-65899c769f-hg7gv   1/1       Running   0          25s
 # nginx-65899c769f-qjmxv   1/1       Running   0          24s
 # nginx-65899c769f-wnnsj   1/1       Running   0          24s

5. 삭제

삭제를 하기 위해서는 Deployments를 제거해야함.
 > kubectl delete deploy nginx
 # deployment.extensions "nginx" deleted

 > kubectl get po
 # No resources found.