
시나리오
1. Deployment 생성
- replicas 2개
- labels는
- app: mainui, version: stable
- 이름 nginx-stable
- 이미지 nginx 1.14
- Deployment 생성
- replicas 2개
- labels는 app: mainui, version: canary
- 이름 nginx-canary
- 이미지 nginx 1.15
- 단일진입점 생성
- Service를 80포트
- labels는 app: mainui
- 이름 mainui-svc
- curl 명령어로 웹페이지 확인 후 canary 버전의 로그 확인
- replicas 개수를 canary 3개 stable 1개로 변경하기
# vi nginx-stable.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mainui-stable
spec:
replicas: 2
selector:
matchLabels:
app: mainui
version: stable
template:
metadata:
labels:
app: mainui
version: stable
spec:
containers:
- name: mainui
image: nginx:1.14
ports:
- containerPort: 80
# vi nginx-canary.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mainui-canary
spec:
replicas: 2
selector:
matchLabels:
app: mainui
version: canary
template:
metadata:
labels:
app: mainui
version: canary
spec:
containers:
- name: mainui
image: nginx:1.15
ports:
- containerPort: 80
# vi mainui-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: mainui-svc
spec:
selector:
app: mainui
ports:
- port: 80
protocol: TCP
targetPort: 80
# Pod 생성
$ kubectl create -f nginx-stable.yaml -f nginx-canary.yaml -f mainui-svc.yaml
# 서비스 및 Deploy 생성 확인
$ kubectl describe service mainui-svc
$ kubectl get deployment.apps
# 접속 확인
$ curl <Service IP>:<Service Port>
# 로그 확인
$ kubectl logs deployment.apps nginx-canary
# canary pod 개수 증가
$ kubectl scale deployment nginx-canary --replicas=3
# 증가된 Pod 개수 확인
$ kubectl describe deployment.apps