아래와 같이 yaml 파일을 작성한다.
구조를 보면 알겠지만, deployment는 replicas를 포함한다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-jenkins
labels:
app: jenkins
spec:
replicas: 3
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins
ports: 8080
아래 명령을 통해 deployment를 생성하고 pod을 확인한다.
kubectl create -f <파일명>
그림과 같이 정상적으로 pod이 생성되는것을 확인할수 있다.
아래 명령을 통해 좀더 자세히 본다.
kubectl get all
그림과 같이, replicaset과 service가 함께 생성되었다.
deployment는 replication controller를 포함하고 있다고 보면 된다.
따라서 rc와 동일하게 scale 가능하고 label명 변경시 replicas가 변경된다는것을 확인할수 있다.
kubectl scale deploy deploy-jenkins --replicas=7