Search

ReplicaSets

부하 분산 및 고가용성 제공
rc-definition.yml
apiVersion: v1 kind: ReplicationController metadata: name: myapp-rc labels: app: myapp type: front-end spec: replicas: 2 template: metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-container image: nginx
Shell
복사
확인
# 배포 kubectl create -f re-definition.yml # 정책 확인 kubectl get replicationcontroller # 배포 확인 kubectl get pods
Shell
복사
replicaset-definition.yml
apiVersion: apps/v1 kind: ReplicaSet metadata: name: myapp-replicaset labels: app: myapp type: front-end spec: replicas: 2 selector: matchLabels: type: front-end template: metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-container image: nginx # selector로 라벨 기능 추가 설정 가능
Shell
복사
확인
# 배포 kubectl create -f replicaset-definition.yml # 정책 확인 kubectl get replicaset # 배포 확인 kubectl get pods
Shell
복사
변경법
# yaml 내에서 숫자 변경 후 kubectl replace -f { 변경파일 } # 임의 숫자 변경을 cli 입력 kubectl scale --replicas=6 -f { 파일 }
Shell
복사