ReplicaSets
ํใ ฃ
ํ๋์ ํ๋๊ฐ ์ฅ์ ๋ฌ์ ๋ ๋ณต์ ์ปจํธ๋กค๋ฌ๊ฐ ๋ณต๊ตฌ๋ ํ ์ ์๋ค.
LB & ์ค์ผ์ผ๋ง ์ฉ๋

Replication Controller & Replica Set
Replication Controller : ๊ตฌํ
Replica Set : ์ ํ (๊ถ์ฅ)
replication Controller ์์ฑ ๋ฐฉ๋ฒ

pod ํฌํ๋ฆฟ์ ์ง์ ํด์ ์์ฑํ๋ค.
# ์์
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp-rc
label:
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: 3Replica Sets ์์ฑ ๋ฐฉ๋ฒ
# ์์
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 selector ํ์
# ReplicaSet ์์ฑ
kubectl create -f replicaset-sefinition.yaml
# ReplicaSet ํ์ธ
kubectl get replicaset
# ReplicaSet๋ก ๋ง๋ pod ํ์ธ
kubectl get podsLabels and Selectors

์คํ ์ค์ธ pod์ ๋ผ๋ฒจ์ ๋ถ์ฌํ์ฌ ReplicaSet์ด ๋ชจ๋ํฐ๋ง ํ ์ ์๋ค.
์คํ์ค์ธ pod๊ฐ ๊ต์ฅํ ๋ง์ ๊ฒฝ์ฐ ์ ์ฉํ๋ค
Scale
replicas ๋ฅผ ๋๋ฆฌ๋ ๋ฐฉ๋ฒ
...
replicas: 6
...kubectl replace -f replicaset-sefinition.yamlํ์ผ ๋ด์ฉ ๊ธฐ๋ฐ์ผ๋ก Replicaset์ ๊ต์ฒดํ๋ค. ๊ธฐ์กด์ replicaset์ด ์ ๊ฑฐ๋๊ณ ์๋กญ๊ฒ ์์ฑ๋์ด ์๋น์ค ์ค๋จ์ด ๋ฐ์ ํ ์์๋ค.
kubectl scale --replicas=6 -f replicaset-sefinition.yamlํด๋น ํ์ผ์ ์ฐพ์ replicas ์๋ฅผ 6์ผ๋ก ์กฐ์ ํ๋ ํ์ผ์ ์ ์๋ replicas๋ ์์ ๋์ง ์์
kubectl scale --replicas=6 replicaset myapp-replicaset์ด๋ฆ์ด myapp-replicaset์ธ ํน์ replicaset์ replicas ์๋ฅผ 6์ผ๋ก ์กฐ์ ํ๋ค.
command
kubectl create -f replicaset-definition.yaml
kubectl get replicaset
kubectl delete replicaset [name]
kubectl replace -f replicaset-definition.yml
kubectl scale --replicas=6 -f replicaset-definition.yamlLast updated