이번엔 ReplicaSet 에 대해 정리하고자 한다.
1. 정의
- 지정한 수만큼 Pod 가 항상 실행되도록 보장하는 컨트롤러
2. 특징
- 지정된 replica 수 유지
- Pod 자동 생성 및 복구
- 레이블 셀렉터 (Label Selector) 기반 관리
3. 한계
- Pod 업데이트 어려움
- 롤링 업데이트 불가
- 실무에서 쓰기 제한적
> Deployment 사용이 표준
4. 관련 문제 (KodeKloud 에서 제공하는 샘플 문제를 정리)
- How many ReplicaSets exist on the system?
> In the current(default) namespace.
kubectl get replicaset
- Create a ReplicaSet using the ‘replicaset-definition-1.yaml’ file located at ‘/root’.
> There is an issue with the file, so try to fix it.
kubectl api-resources | grep replicaset
kubectl explain replicaset | grep VERSION
(replicaset-definition-1.yaml 파일에서 apiVersion 수정 후) kubectl create -f /root/replicaset-definition-1.yaml
- Fix the original replica set new-replica-set to use the correct busybox image.
> Either delete and recreate the ReplicaSet or update the existing ReplicaSet and then delete all PODs, so new ones with the correct image will be created. If you opt to delete the ReplicaSet and recreate it, please refer to the file named new-replica-set.yaml, which is saved in the /root/ directory for your convenience and fix it.
kubectl edit replicaset new-replica-set
- Scale the ReplicaSet to 5 PODs.
> Use kubectl scale command or edit the replicaset using kubectl edit replicaset.
kubectl scale rs new-replica-set --replicas=5
- Now scale the ReplicaSet down to 2 PODs.
> Use the kubectl scale command or edit the replicaset using kubectl edit replicaset.
kubectl scale rs new-replica-set --replicas=2
5. 출처
'IT > Kubernetes' 카테고리의 다른 글
| [CKA] PV(PersistentVolume) 란? (0) | 2025.11.22 |
|---|---|
| [CKA] StorageClass 란? (0) | 2025.11.21 |
| [CKA] PriorityClass 란? (0) | 2025.11.21 |
| [CKA] Deployment 란? (0) | 2025.11.21 |
| [CKA] Pod 란? (0) | 2025.11.20 |