레플리케이션 컨트롤러

레플리케이션 컨트롤러 (ReplicationController)

출처: Kubernetes 공식 문서 — ReplicationController

ReplicationController는 수평 확장이 가능한 워크로드를 관리하는 레거시 API예요. Deployment와 ReplicaSet API에 의해 대체되었습니다.

참고: 이제는 ReplicaSet을 설정하는 Deployment가 레플리케이션을 구성하는 권장 방법이에요.

ReplicationController는 지정된 수의 파드 레플리카가 항상 실행되고 있음을 보장합니다. 즉, 특정 파드 또는 동질적인 파드 집합이 항상 실행되고 사용 가능하도록 만들어 줘요.

예제 ReplicationController 실행 (Running an example ReplicationController)

이 예시는 nginx 웹 서버의 복사본 3개를 실행하는 설정이에요.

apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 3
  selector:
    app: nginx
  template:
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

실행 결과를 확인해 보면 3개의 현재/원하는 레플리카와 생성된 파드 이름(nginx-3ntk0, nginx-4ok8v, nginx-qrm3m)을 볼 수 있어요.

ReplicationController 매니페스트 작성 (Writing a ReplicationController Manifest)

파드 템플릿 (Pod Template)

.spec.template.spec.restartPolicyAlways만 허용돼요(지정하지 않으면 기본값). 로컬 컨테이너 재시작은 Kubelet 같은 노드의 에이전트에게 위임합니다.

일반적인 사용 패턴 (Common usage patterns)

롤링 업데이트 (Rolling updates)

두 ReplicationController는 최소한 하나의 구분되는 라벨(예: 파드의 기본 컨테이너 이미지 태그)로 파드를 만들어야 해요. 보통 롤링 업데이트의 동기는 이미지 업데이트이기 때문입니다.

ReplicationController의 책임 (Responsibilities of the ReplicationController)

ReplicationController는 조합 가능한 빌딩 블록 프리미티브로 설계됐어요. 나중에 더 높은 수준의 API나 도구가 그 위에 구축되길 기대합니다.

API 객체 (API Object)

ReplicationController는 쿠버네티스 REST API의 최상위 리소스예요. API 객체에 대한 자세한 내용은 ReplicationController API object 문서를 참고하세요.

ReplicationController의 대안 (Alternatives to ReplicationController)

ReplicaSet

ReplicaSet은 셋 기반의 라벨 셀렉터를 지원하는 차세대 ReplicationController예요. 주로 Deployment가 파드 생성·삭제·업데이트를 오케스트레이션하는 메커니즘으로 사용합니다.

Bare Pods

ReplicationController도 로컬 컨테이너 재시작을 kubelet 같은 노드의 에이전트에게 위임합니다.

다음 단계 (What's next)

더 알아보기 (Learn more)