Replication Controller 和 Replica Set

Use Replication Controller, Replica Set management Pod

Replication Controller (RC)

Abbreviated as RC, rc can be used as a quick managed objects kubectl tools for managing multiple Pod resource object, the object for more than a pod. If the pod number is too large, delete and more, if the pod to reduce the number, there are pod unhealthy or shoot down, restart a pod, ensure that the total number of the same pod, mainly used to deploy, upgrade Pod

Use RC Management Pod

apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicat: 3            #设置副本数量
  selector:
    app: nginx          #选择管理的Pod 标签
  template:
    metadata:
      labels:
        app: nginx      #必须和selector选择的标签一致
    spec:
      containers:
      - name: nginx
        image: nginx
        imagePullPolicy: IfNotPresent
        ports:
        - name: http
          containerPort: 80

Pod resources compared to the target deployment template file, rc remained almost the same, need apiVersion, kind, metadata, spec, except that rc in more spec.template field, is under spec.template Pod template and Pod resource object the same format.

Replica Set(RS)

Abbreviated as RS, the RC generation, essentially the same function, except that, the RC supports only equation label selected selector (env = dev or environment! = Qa), RS also supports a set of selector (version in (v1.0 , v2.0))

Official template

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: frontend
  labels:
    app: guestbook
    tier: frontend
spec:
  # modify replicas according to your case
  replicas: 3
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      labels:
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google_samples/gb-frontend:v3

About summarize RC/ RSsome of the features and functions of it:

  • In most cases, we can define a RCrealization of Podcreation and number of copies of control
  • RCContains a full Poddefinition module (not included apiversionand kind)
  • RCThrough label selectorto implement the mechanism of Podcontrol copies of
  • By changing the RCinside of Podnumber of copies, may be implemented Podexpansion volume reduction function
  • By changing the RCinside of Podthe template image version, you can achieve Poda rolling upgrade functionality (but does not support a key roll back, you need to modify the mirror address in the same way)
  • Pod as RS retractable horizontal scaler (HPA)

Guess you like

Origin www.cnblogs.com/h-gallop/p/11809664.html