본문 바로가기
Framework and Tool/Docker

Swarm - Rolling update

by ocwokocw 2023. 10. 2.

- 출처: https://docs.docker.com/engine/swarm/swarm-tutorial/rolling-update/

 

Apply rolling updates to a service

Apply rolling updates to a service on the swarm

docs.docker.com

 

- Deploy test service, Redis 3.0.6

Redis 3.0.6 컨테이너 tag 기반의 서비스를 배포하고, 이를 rolling update 방식으로 Redis 3.0.7 로 갱신해보자.

[ec2-user@ip-172-31-36-249 ~]$ docker service create --replicas 3 --name redis --update-delay 10s redis:3.0.6
0356dgubjzi93a3e9h6510u7z
overall progress: 3 out of 3 tasks
1/3: running   [==================================================>]
2/3: running   [==================================================>]
3/3: running   [==================================================>]
verify: Service converged
  • --update-delay flag는 service task나 task set에 대한 갱신시 간격을 설정한다. 기본적으로 scheduler는 한번에 1 task만 갱신한다. --update-parallelism flag를 사용하면 동시에 갱신하는 service task 수를 설정할 수 있다.
  • 기본적으로 task를 갱신하면 RUNNING 상태를 반환하는데, scheduler는 모든 task가 갱신될때까지 이를 scheduling 한다. 만약 task가 갱신도중 FAILED를 반환하면 갱신을 멈춘다. --update-failure-action flag를 사용하면 docker service create나 docker service update 행동을 제어할 수 있다.

- Inspect Redis

[ec2-user@ip-172-31-36-249 ~]$ docker service inspect --pretty redis

ID:		0356dgubjzi93a3e9h6510u7z
Name:		redis
Service Mode:	Replicated
 Replicas:	3
Placement:
UpdateConfig:
 Parallelism:	1
 Delay:		10s
 On failure:	pause
 Monitoring Period: 5s
 Max failure ratio: 0
 Update order:      stop-first
RollbackConfig:
 Parallelism:	1
 On failure:	pause
 Monitoring Period: 5s
 Max failure ratio: 0
 Rollback order:    stop-first
ContainerSpec:
 Image:		redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842
 Init:		false
Resources:
Endpoint Mode:	vip

- Update image

"docker service update --image" 명령어를 사용해서 redis version up을 진행해보자.

[ec2-user@ip-172-31-36-249 ~]$ docker service update --image redis:3.0.7 redis
redis
overall progress: 3 out of 3 tasks
1/3: running   [==================================================>]
2/3: running   [==================================================>]
3/3: running   [==================================================>]
verify: Service converged

위의 결과만으로는 제대로 동작했는지 확인하기 힘들다. "docker service ps" 명령어를 통해 task 들을 조회해보자.

[ec2-user@ip-172-31-36-249 ~]$ docker service ps redis
ID             NAME          IMAGE         NODE                                               DESIRED STATE   CURRENT STATE            ERROR     PORTS
pfppo64atzv8   redis.1       redis:3.0.7   ip-172-31-46-128.ap-northeast-2.compute.internal   Running         Running 2 minutes ago
rvovuf4d26f4    \_ redis.1   redis:3.0.6   ip-172-31-46-128.ap-northeast-2.compute.internal   Shutdown        Shutdown 2 minutes ago
xhtrbm9iaexm   redis.2       redis:3.0.7   ip-172-31-45-73.ap-northeast-2.compute.internal    Running         Running 2 minutes ago
ii1d0qb1ge6q    \_ redis.2   redis:3.0.6   ip-172-31-45-73.ap-northeast-2.compute.internal    Shutdown        Shutdown 2 minutes ago
phwibgap1tt9   redis.3       redis:3.0.7   ip-172-31-36-249.ap-northeast-2.compute.internal   Running         Running 2 minutes ago
3ev55kagct52    \_ redis.3   redis:3.0.6   ip-172-31-36-249.ap-northeast-2.compute.internal   Shutdown        Shutdown 2 minutes ago

 

'Framework and Tool > Docker' 카테고리의 다른 글

Swarm - routing mesh  (1) 2023.10.08
Swarm - drain node  (0) 2023.10.02
Swarm mode tutorial  (0) 2023.10.02
Swarm mode overview and concepts  (0) 2023.09.17
Build Context  (0) 2023.08.12

댓글