오늘도 한 뼘 더
[k8s] Replica Set(레플리카셋) 본문
728x90
반응형
Replica Set(레플리카셋)
- 일정 개수의 포드를 유지하는 컨트롤러 역할
- 노드 장애 등의 이유로 포드를 사용할 수 없다면 다른 노드에서 포드를 생성할 수 있도록 한다.
- yaml 파일에 여러 개의 리소를 만들도록 지정할 수 있으나 이는 포드 개수를 유지하는 방법은 아니다.
레플리카 셋 사용 전
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod-a
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80
protocol: TCP
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod-b
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80
protocol: TCP
레플리카셋 사용하기
apiVersion: app/v1
kind: ReplicaSet
metadata:
name: nginx-replicaset
spec: |
replicas: 2 |
selector: | //레플리카 셋 정의
matchLabels: |
app: nginx-pods-label |
template: || // 여기서부터는 포드 정의
metadata: ||
name: nginx-pod
labels:
app: nginx-pods-label
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80
protocol: TCP
- spec.replicas : replica 몇 개를 만들지
- spec.selector.matchLabels : 레플리카셋에서 어떤 포드를 관리할지를 라벨로 정의한다.
728x90
반응형
'DevOps & Infra > K8S(Kubernetes)' 카테고리의 다른 글
[k8s] error: Metrics API not available (0) | 2023.01.09 |
---|---|
[k8s] Deployment(디플로이먼트) (0) | 2023.01.02 |
[k8s] Pod (포드) (0) | 2022.12.13 |
[k8s] Kubernetes(쿠버네티스) (0) | 2022.12.13 |
[k8s] Secret.yaml 파일 사용하여 환경변수 보호하기 (0) | 2022.11.30 |
Comments