"Kubectl scale"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
 
11번째 줄: 11번째 줄:


==스케일 업 1→4==
==스케일 업 1→4==
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl get deployments
$ kubectl get deployments
NAME                  DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
NAME                  DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
kubernetes-bootcamp  1        1        1            1          1m
kubernetes-bootcamp  1        1        1            1          1m
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl scale deployments/kubernetes-bootcamp --replicas=4
$ kubectl scale deployments/kubernetes-bootcamp --replicas=4
deployment "kubernetes-bootcamp" scaled
deployment "kubernetes-bootcamp" scaled
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl get deployments
$ kubectl get deployments
NAME                  DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
NAME                  DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
kubernetes-bootcamp  4        4        4            4          1m
kubernetes-bootcamp  4        4        4            4          1m
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl get pods -o wide
$ kubectl get pods -o wide
NAME                                  READY    STATUS    RESTARTS  AGE  IP          NODE
NAME                                  READY    STATUS    RESTARTS  AGE  IP          NODE
32번째 줄: 32번째 줄:
kubernetes-bootcamp-5dbf48f7d4-mgsjj  1/1      Running  0          3m  172.18.0.4  host01
kubernetes-bootcamp-5dbf48f7d4-mgsjj  1/1      Running  0          3m  172.18.0.4  host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b  1/1      Running  0          1m  172.18.0.6  host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b  1/1      Running  0          1m  172.18.0.6  host01
</source>
</syntaxhighlight>


==스케일 다운 4→2==
==스케일 다운 4→2==
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl scale deployments/kubernetes-bootcamp --replicas=2
$ kubectl scale deployments/kubernetes-bootcamp --replicas=2
deployment "kubernetes-bootcamp" scaled
deployment "kubernetes-bootcamp" scaled
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl get deployments
$ kubectl get deployments
NAME                  DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
NAME                  DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
kubernetes-bootcamp  2        2        2            2          13m
kubernetes-bootcamp  2        2        2            2          13m
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl get pods -o wide
$ kubectl get pods -o wide
NAME                                  READY    STATUS        RESTARTS  AGE      IP          NODE
NAME                                  READY    STATUS        RESTARTS  AGE      IP          NODE
51번째 줄: 51번째 줄:
kubernetes-bootcamp-5dbf48f7d4-mgsjj  1/1      Running      0          13m      172.18.0.4  host01
kubernetes-bootcamp-5dbf48f7d4-mgsjj  1/1      Running      0          13m      172.18.0.4  host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b  1/1      Running      0          11m      172.18.0.6  host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b  1/1      Running      0          11m      172.18.0.6  host01
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl get pods -o wide
$ kubectl get pods -o wide
NAME                                  READY    STATUS    RESTARTS  AGE  IP          NODE
NAME                                  READY    STATUS    RESTARTS  AGE  IP          NODE
kubernetes-bootcamp-5dbf48f7d4-mgsjj  1/1      Running  0          16m  172.18.0.4  host01
kubernetes-bootcamp-5dbf48f7d4-mgsjj  1/1      Running  0          16m  172.18.0.4  host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b  1/1      Running  0          14m  172.18.0.6  host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b  1/1      Running  0          14m  172.18.0.6  host01
</source>
</syntaxhighlight>


==히스토리 확인==
==히스토리 확인==
<source lang='console'>
<syntaxhighlight lang='console'>
$ kubectl describe deployments/kubernetes-bootcamp | tail
$ kubectl describe deployments/kubernetes-bootcamp | tail
   ----          ------  ------
   ----          ------  ------
72번째 줄: 72번째 줄:
   Normal  ScalingReplicaSet  14m  deployment-controller  Scaled up replica set kubernetes-bootcamp-5dbf48f7d4 to 4
   Normal  ScalingReplicaSet  14m  deployment-controller  Scaled up replica set kubernetes-bootcamp-5dbf48f7d4 to 4
   Normal  ScalingReplicaSet  3m    deployment-controller  Scaled down replicaset kubernetes-bootcamp-5dbf48f7d4 to 2
   Normal  ScalingReplicaSet  3m    deployment-controller  Scaled down replicaset kubernetes-bootcamp-5dbf48f7d4 to 2
</source>
</syntaxhighlight>


==실습==
==실습==
<source lang='console'>
<syntaxhighlight lang='console'>
testuser@localhost:~$ kubectl create deployment nginx --image=nginx
testuser@localhost:~$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
deployment.apps/nginx created
91번째 줄: 91번째 줄:
NAME    ENDPOINTS                                                AGE
NAME    ENDPOINTS                                                AGE
nginx  192.168.189.65:80,192.168.219.68:80,192.168.235.136:80  55s
nginx  192.168.189.65:80,192.168.219.68:80,192.168.235.136:80  55s
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2023년 12월 11일 (월) 13:32 기준 최신판

1 개요[ | ]

kubectl scale
kubectl scale -n 네임스페이스 deploy/디플로이 --replicas=수량
kubectl scale -n dev deploy/nginx --replicas=3

2 스케일 업 1→4[ | ]

$ kubectl get deployments
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubernetes-bootcamp   1         1         1            1           1m
$ kubectl scale deployments/kubernetes-bootcamp --replicas=4
deployment "kubernetes-bootcamp" scaled
$ kubectl get deployments
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubernetes-bootcamp   4         4         4            4           1m
$ kubectl get pods -o wide
NAME                                   READY     STATUS    RESTARTS   AGE  IP           NODE
kubernetes-bootcamp-5dbf48f7d4-6tvt9   1/1       Running   0          1m  172.18.0.7   host01
kubernetes-bootcamp-5dbf48f7d4-jhcs8   1/1       Running   0          1m  172.18.0.5   host01
kubernetes-bootcamp-5dbf48f7d4-mgsjj   1/1       Running   0          3m  172.18.0.4   host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b   1/1       Running   0          1m  172.18.0.6   host01

3 스케일 다운 4→2[ | ]

$ kubectl scale deployments/kubernetes-bootcamp --replicas=2
deployment "kubernetes-bootcamp" scaled
$ kubectl get deployments
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubernetes-bootcamp   2         2         2            2           13m
$ kubectl get pods -o wide
NAME                                   READY     STATUS        RESTARTS   AGE      IP           NODE
kubernetes-bootcamp-5dbf48f7d4-6tvt9   1/1       Terminating   0          11m      172.18.0.7   host01
kubernetes-bootcamp-5dbf48f7d4-jhcs8   1/1       Terminating   0          11m      172.18.0.5   host01
kubernetes-bootcamp-5dbf48f7d4-mgsjj   1/1       Running       0          13m      172.18.0.4   host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b   1/1       Running       0          11m      172.18.0.6   host01
$ kubectl get pods -o wide
NAME                                   READY     STATUS    RESTARTS   AGE  IP           NODE
kubernetes-bootcamp-5dbf48f7d4-mgsjj   1/1       Running   0          16m  172.18.0.4   host01
kubernetes-bootcamp-5dbf48f7d4-v5h6b   1/1       Running   0          14m  172.18.0.6   host01

4 히스토리 확인[ | ]

$ kubectl describe deployments/kubernetes-bootcamp | tail
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
OldReplicaSets:  <none>
NewReplicaSet:   kubernetes-bootcamp-5dbf48f7d4 (2/2 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  16m   deployment-controller  Scaled up replica set kubernetes-bootcamp-5dbf48f7d4 to 1
  Normal  ScalingReplicaSet  14m   deployment-controller  Scaled up replica set kubernetes-bootcamp-5dbf48f7d4 to 4
  Normal  ScalingReplicaSet  3m    deployment-controller  Scaled down replicaset kubernetes-bootcamp-5dbf48f7d4 to 2

5 실습[ | ]

testuser@localhost:~$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
testuser@localhost:~$ kubectl expose deployment nginx --type=NodePort --port 80
service/nginx exposed
testuser@localhost:~$ kubectl get ep nginx
NAME    ENDPOINTS            AGE
nginx   192.168.235.136:80   6s
testuser@localhost:~$ kubectl scale deployment nginx --replicas=3
deployment.extensions/nginx scaled
testuser@localhost:~$ kubectl get deployments nginx 
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   3/3     3            3           64s
testuser@localhost:~$ kubectl get ep nginx
NAME    ENDPOINTS                                                AGE
nginx   192.168.189.65:80,192.168.219.68:80,192.168.235.136:80   55s

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}