애플리케이션을 실행하는 단일 파드가 있는 시나리오
어떤 이유로 애플리케이션이 충돌하고 파드가 실패하여 사용자가 더 이상 애플리케이션에 액세스할 수 없게 되다
사용자가 애플리케이션에 대한 액세스 권한을 잃는 것을 방지하기 위해 둘 이상의 인스턴스 또는 파드가 동시에 실행되도록 하기 = 이중화
한 쪽이 실패하더라도 다른 쪽에서 애플리케이션을 계속 실행 가능
둘 다 같은 목적이지만 같지 않음
vi rc-definition.yml
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp-rc
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
kubectl create -f rc-definition.yml를 통해 실행kubectl get replicationcontroller: 코딩할 때 변수명 저렇게 적어두면 욕먹는데.. K8s는 아닌가보다vi replicaset-definition.yml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end
kubectl create -f replicaset-definition.ymlkubectl get replicasetkubectl get pods세 부분으로 구성된 front-end web application의 인스턴스를 3개 배포했다고 가정
RC 또는 RS로 3개의 활성 pod 유지

kubectl scale --replicas=6 -f replicaset-definition.yml로 수정하기kubectl scale --replicas=6 replicaset myapp-replicaset로 type과 name 지정하여 수정하기kubectl create -f replicaset-definition.ymlkubectl get replicasetkubectl delete replicaset myapp-replicasetkubectl replace -f replicaset-definition.ymlkubectl scale --replicas=6 replicaset myapp-replicaset