■ Deployment Strategy
서비스 배포 전략 기법에는 Recreate, Rolling Update, Blube/Green, Canary 배포 전략이 있다.
▣ Recreate
- 가장 단순한 배포 전략으로, 기존 버전의 서버를 모두 삭제한 다음 새로운 버전의 서버를 생성하는 방법
- 서비스에 대한 일시적인 DownTime(중단 시간)이 존재한다. (무중단 배포 X)
<실습- recreate>
vi 1.yaml 생성하기
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-1
spec:
selector:
matchLabels:
type: app
replicas: 2
strategy:
type: Recreate
revisionHistoryLimit: 1
template:
metadata:
labels:
type: app
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 10
vi 2.yaml 생성
apiVersion: v1
kind: Service
metadata:
name: svc-1
spec:
selector:
type: app
ports:
- port: 8080
protocol: TCP
targetPort: 8080
2.yaml 파일 실행후 1.yaml 파일 실행
# watch kubectl get all –o wide
--------------------------------------------------------------------
# kubectl get pods --show-labels
# kubectl get pods -l type //-l (label)옵션 사용하기
# kubectl get pods -l type=app //-l (label)옵션 사용하기
# kubectl describe pod/deployment-1-7fb6d9dc-2np2t
Controlled By: ReplicaSet/deployment-1-7fb6d9dc
# kubectl describe replicaset.apps/deployment-1-7fb6d9dc
Controlled By: Deployment/deployment-1
master에서 Cluster IP 에 반복해서 접근하기
root@master:~# while true; do curl 10.96.251.8:8080/version; sleep 1; done
Deployment 편집으로 image를 v1에서 v2로 변경하고 마스터 노드 쉘 보기
# kubectl edit deployment.apps/deployment-1
ReplicaSet 확인 : 기존 파드 v1은 2->0이 되고, v2는 2개가 생성됨 # watch kubectl get all –o wide
▣ Rolling Update
- 기존 버전의 서버를 하나씩 죽이고, 새로운 버전의 서버를 하나씩 띄우면서 순차적으로 교체하는 방법이다. 즉, 서버를 하나하나씩 버전을 업그레이드하는 방식
- 배포 중 추가 자원을 요구하지만, 서비스 DownTime 시간이 없음
- 하지만, 이전의 버전과 새로운 버전이 공존하는 시간이 발생하는 단점이 있음
• ReCreate과 달리 v1을 삭제하지 않고 v2를 생성
• 자원은 3개가 되고, 접속하는 사람은 v1이나 v2에 접속하게 됨
• v1을 삭제하고, v2 생성
• 마지막으로 남은 v1을 삭제하여 v2로 업데이트 완료
• 단점: 자원을 추가로 요구, 장점: DownTime이 없음
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-2
spec:
selector:
matchLabels:
type: app2
replicas: 2
strategy:
type: RollingUpdate
minReadySeconds: 10
template:
metadata:
labels:
type: app2
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 0
# minReadySeconds: 롤링업데이트를 지켜보기 위해
# 텀을 주는 명령어
master에서 Cluster IP 에 반복해서 접근하기
# while true; do curl 10.96.251.8:8080/version; sleep 1; done Deployment
편집으로 image를 v1에서 v2로 변경하고 마스터 노드 쉘 보기
# kubectl edit deployment.apps/deployment-2
'가상화 > Kubernetes' 카테고리의 다른 글
[Kubernetes] Deployment (0) | 2023.05.16 |
---|---|
[Kubernetes] ReplicaSet (0) | 2023.05.16 |
[Kubernetes] kubectl (0) | 2023.05.12 |
댓글