Rollout은 애플리케이션을 점진적으로 업데이트하거나 롤백하는 프로세스를 의미한다.
Rollout은 주로 Deployment와 함께 사용되며, Kubernetes가 애플리케이션의 가용성을 유지하면서 업데이트를 수행하도록 보장한다.
- 점진적 업데이트:
- 애플리케이션의 새로운 버전이 기존 버전을 대체할 때, 모든 Pod을 한 번에 교체하지 않고 점진적으로 업데이트.
- 가용성 유지:
- 업데이트 중에도 애플리케이션이 가용성을 유지하도록 보장.
- 롤백 지원:
- 새로운 버전 배포 중 문제가 발생하면 간단히 이전 버전으로 되돌릴 수 있음.
- 히스토리 관리:
- 이전 배포 내역(Revision)을 저장하여 롤백과 관리에 활용.
strategy
(1) RollingUpdate (기본값)
- Pod를 순차적으로 교체
- 일부 Pod는 기존 버전을 실행하며, 다른 일부는 새 버전을 실행하여 가용성을 유지.
- maxUnavailable: 교체 중 사용할 수 없는 Pod의 최대 수(기본값: 25%).
- maxSurge: 교체 중 추가로 생성할 수 있는 Pod의 최대 수(기본값: 25%).
- Rolling Update의 속도는 maxUnavailable과 maxSurge 값에 의존하여 제한될 수 있으니 작게 설정하는 것이 Best!
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
(2) Recreate
- 모든 기존 Pod를 종료한 후 새로운 Pod를 생성.
- 무중단 업데이트가 필요하지 않은 경우에 사용.
$ kubectl describe deployments.apps frontend
Name: frontend
Namespace: default
CreationTimestamp: Wed, 08 Jan 2025 01:13:43 +0000
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: name=webapp
Replicas: 4 desired | 4 updated | 4 total | 4 available | 0 unavailable
StrategyType: RollingUpdate # 롤링업데이트로 설정됨
MinReadySeconds: 20
RollingUpdateStrategy: 25% max unavailable, 25% max surge # 한번에 25%만 철거 가능
Pod Template:
Labels: name=webapp
Containers:
simple-webapp:
Image: kodekloud/webapp-color:v1
Port: 8080/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Node-Selectors: <none>
Tolerations: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: frontend-7b5df69f4 (4/4 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 4m15s deployment-controller Scaled up replica set frontend-7b5df69f4 to 4
- Recreate Strategy로 변경
$ kubectl edit deploy frontend
deployment.apps/frontend edited
strategy:
type: Recreate
- Deployment의 image바꾸면서 Upgrade하기
kubectl set image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N
# Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox container image to 'busybox'
$ kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
$ kubectl edit deploy frontend
..
spec:
containers:
- image: kodekloud/webapp-color:v1 # 수정하기
# 또는 kubectl set image 이용하기
# kubectl set image deploy <deployment name> <container name>=<image>
$ kubectl set image deploy frontend simple-webapp=kodekloud/webapp-color:v2
deployment.apps/frontend image updated
$ kubectl describe deploy frontend
Name: frontend
Namespace: default
CreationTimestamp: Wed, 08 Jan 2025 01:13:43 +0000
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 2
Selector: name=webapp
Replicas: 4 desired | 4 updated | 4 total | 4 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 20
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: name=webapp
Containers:
simple-webapp:
Image: kodekloud/webapp-color:v2
반응형
'Container > Kubernetes' 카테고리의 다른 글
[K8S] Encrypting Secret Data at Rest (0) | 2025.01.08 |
---|---|
[K8S] ConfigMap (0) | 2025.01.08 |
[K8S] Static Pods (0) | 2025.01.07 |
[K8S] Endpoints (0) | 2025.01.02 |
[K8S] Deployment (0) | 2024.12.31 |