2-4. ReplicaSet으로 고가용성 시스템 만들기

황인권·2025년 2월 8일

Kubernetes

목록 보기
11/37

ReplicaSet 생성

  1. 아래와 같이 yaml 파일 생성
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: sample-replicaset
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.27.0
        ports:
        - containerPort: 80
  1. Pod를 생성했을 때와 같이 yaml파일 apply
kubectl apply -f sample-replicaset.yaml

ReplicaSet으로 만들어진 Pod 확인해보기

  1. kubectl get replicasets를 입력해서 생성된 ReplicaSet 확인
  2. kubectl get pods를 입력하여, 실제로 ReplicaSet이 Pod를 생성했나 확인

진짜 Pod가 복구되는가?

  • 아래 명령어를 임력하여 임의로 Pod를 하나 죽여보자
kubectl delete pod <pod 이름>
  • 잠시 후에 다시 Pod를 조회해보면, 방금 죽인 Pod를 대체할 Pod를 ReplicaSet이 생성해낸 모습을 확인할 수 있다.
profile
inkwon Hwang

0개의 댓글