9.4 ReplicaSet 과 ReplicationController

1812 단어 dockerk8s
ReplicationController
새 podnginx.yml
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

그리고 다음 과 같이 실행 합 니 다.
kubectl create -f pod_nginx.yml
kubectl get rc

NAME
DESIRED
CURRENT
READY
AGE
nginx
3
3
3
4m
kubectl get pods

NAME
READY
STATUS
RESTARTS
AGE
nginx-89s9p
1/1
Running
0
6m
nginx-8bjnb
1/1
Running
0
6m
nginx-h49m5
1/1
Running
0
6m
kubectl delete pods nginx-89s9p
kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-2mvs9 0/1 ContainerCreating 0 
nginx-89s9p 0/1 Terminating 0 9m
nginx-8bjnb 1/1 Running 0 9m
nginx-h49m5 1/1 Running 0 9m

우리 가 pod 를 삭제 할 때, kube 는 자동 으로 다른 pod 를 만들어 서 동적 균형 을 이룬다
#     pod  
kubectl scale rc nginx --replicas=2

ReplicaSet
새 podnginx.yml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: nginx
  labels:
    tier: frontend
spec:
  replicas: 3
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      name: nginx
      labels:
        tier: frontend
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
          - containerPort: 80

집행 하 다.
#   
kubectl create -f pod_nginx.yml

#   
kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx 3 3 3 2m

#   
kubectl scale rs nginx --replicas=1

좋은 웹페이지 즐겨찾기