쿠버네티스 레플리케이션컨트롤러, 레플리카셋

신상우·2023년 12월 29일

쿠버네티스

목록 보기
17/26

19버전에서 레플리카셋 이 등장 좀더 개선됨 !

https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/

조회 : kubectl get rs
상세조회: kubectl describe rs NAME
삭제: kubectl delete rs NAME

기본설정이 5분

yaml 파일 만들기

  1. gedit http-go-rc.yaml
  2. https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/
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

template-app 과selector-app 이 같아야한다!

  1. kubectl create -f http-go-rc.yaml

  2. kubectl get rc

  3. kubectl get pod

  4. pod NAME deleted 후 다시 kubectl get pod 하면 새로생김

  5. kubectl get pod --show-labels

  6. kubectl label pod NAME app- 삭제후 kubectl get pod --show-labels 하면 확인가능

  7. node 한 끈길경우 임시 pod가 생기고 복구시 임시 pod 는사라지고 다시 연결되는걸 확인할수있음 kubectl get nodes -w, kubectl get pod-w,
    kubectl get pod -o wide

  8. 수정 방법
    a. kubectl scale rc NAME --replicas=5
    b. sudo apt install vim 설치 후 kubectl edit rc NAME 하면 vim으로 열림 spec-에있는 replicas 수정
    c. vim NAME 에서 수정한 파일을 kubectl apply -f NAME 하면 configured 됨

profile
기록 남기기

0개의 댓글