비전공자도 이해할 수 있는 쿠버네티스 입문/실전
✅ 트래픽이 늘어나서 서버를 5개로 늘리고 싶다면?
디플로이먼트(Deployment)를 활용하면 쉽게 서버의 개수를 늘릴 수 있다.
- 매니페스트 파일 수정
spring-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-deployment
spec:
replicas: 5
selector:
matchLabels:
app: backend-app
template:
metadata:
labels:
app: backend-app
spec:
containers:
- name: spring-container
image: spring-server
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
- 변경사항 적용
$ kubectl apply -f spring-deployment.yaml
kubectl apply 명령어는 새롭게 오브젝트(디플로이먼트, 파드 등)를 생성할 때도 사용하고, 변경 사항을 적용시킬 때도 사용할 수 있는 편리한 명령어이다.
- 잘 적용됐는 지 확인하기
$ kubectl get pods