배포 전략
* 참고 : Six Strategies for Application Deployment – The New Stack
Six Strategies for Application Deployment
There are a variety of techniques to deploy new applications to production, so choosing the right strategy is an important decision, weighing the options in terms of the impact of change on the system, and on the end-users. In this post, we are going to t
thenewstack.io
- Recreate: Version A is terminated then version B is rolled out. (기존에 있던 RS를 지우고 새로운 RS 만들어서 연결)
- Ramped (also known as rolling-update or incremental): Version B is slowly rolled out and replacing version A. (하나씩 순차적으로 굴려서 옮기는 형태 / 기존에 있던 pod하나를 지우고 새로운 pod 생성)
- Blue/Green: Version B is released alongside version A, then the traffic is switched to version B. (새로운 version을 미리 만들어놓고 이전 version을 삭제)
- Canary: Version B is released to a subset of users, then proceed to a full rollout. (카나리아새 / 조금씩 흘려보내보고 확인해서 이상이 없으면 옮기는 비율을 늘려가며 버전 이동 / 정찰병 보내듯이)
- A/B testing: Version B is released to a subset of users under specific condition. (특정 대상 그룹을 기준으로 분류 ex. 컴퓨터 사용자는 v1 version으로 모바일 사용자는 v2 version으로 보내버리기)
- Shadow: Version B receives real-world traffic alongside version A and doesn’t impact the response. (사실은 양쪽으로 traffic 보내버리고 문제가 없으면 다음에 v2로 보내기)
Deployments
: Deploy가 → RS → Pods 생성
myweb-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myweb-deploy
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: myweb
image: ghcr.io/c1t1d0s7/go-myweb:v1
ports:
- containerPort: 8080
myweb-svc-lb.yaml
apiVersion: v1
kind: Service
metadata:
name: myweb-svc-lb
spec:
type: LoadBalancer
selector:
app: web
ports:
- port: 80
targetPort: 8080
kubectl rollout status deploy myweb-deploy
kubectl rollout history deploy myweb-deploy
image 교체 (--record : 명령을 히스토리에 저장)
kubectl set image deployments myweb-deploy myweb=ghcr.io/c1t1d0s7/go-myweb:v2.0 --record
image 교체 시, metadata에 annotation 지정해서 활용하기 (--record 효과)
apiVersion: apps/v1
kind: Deployment
metadata:
name: myweb-deploy
annotations:
kubernetes.io/change-cause: "Change Go Myweb version from 3 to 4"
...
kubectl apply -f myweb-deploy.yaml
- maxSurge : Rollingout을 하는 도중에 순간적으로 몇개의 pod가 추가적으로 더 생성될 수 있는지 설정
(ex. 기존에 RS를 통해 3개를 만들었고 maxSurge:1로 설정했다면 - 원래는 pod가 3개를 넘어갈 수 없었지만 - 순간적으로 최대 4개의 pod 까지 ok)
- maxUnavailable : Rollingout을 할 때, 한번에 이전 pod를 최대 몇개까지 없앨건지 설정
apiVersion: apps/v1
kind: Deployment
metadata:
name: myweb-deploy
annotations:
kubernetes.io/change-cause: "Change Go Myweb version from 3 to 4"
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: myweb
image: ghcr.io/c1t1d0s7/go-myweb:v4.0
ports:
- containerPort: 8080
'IT > Kubernetes' 카테고리의 다른 글
[Kubernetes] Auto Scaling (0) | 2022.05.27 |
---|---|
[Kubernetes] StatefulSet (0) | 2022.05.27 |
[Kubernetes] ConfigMap & Secret (0) | 2022.05.25 |
[Kubernetes] Volume (0) | 2022.05.25 |
[Kubernetes] Service & DNS (0) | 2022.05.19 |