쿠버네티스 롤링 업데이트와 배포
· 약 5분
Deployment
Deployment 의 파드 교체 전략에는 RollingUpdate 와 Recreate 가 있다. 기본 값은 RollingUpdate 이며 간단한 설정이 적용된 디플로이먼트는 아래와 같을 것이다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-rolling-update
label:
app: test
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 3
maxSerge: 4
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
containers:
- name: test
image: echo
ports:
- containerPort: 8080
여기서 롤링업데이트 속성을 좀 더 자세히 알아보자.
RollingUpdate
maxUnavailable
- 롤링 업데이트 중 동시에 삭제할 수 있는 파드의 최대 갯수
- 기본 값은 replicas의 25% 이다.
replicas: 4
의 경우 1개 파드 삭제,replicas: 8
의 경우 2개 파드 동시 삭제- 퍼센트 및 직접 지정이 가능하다.
- 위의 예시 디플로이먼트에서 롤링업데이트 시작 시 파드 3개가 바로 죽는다.
- 이 값을 높게 설정하면 동시에 교체되는 파드가 늘어나므로 롤링 업데이트 시간이 줄어든다.
- 하지만 롤링업데이트 중에 남아 있는 파드에 요청 수가 몰릴 수 있다.
- 따라서
1