What is the difference between ReplicaSet and ReplicationController?

后端 未结 3 1961
执念已碎
执念已碎 2021-02-05 00:14

From what I can tell in the documentation, a ReplicaSet is created when running a Deployment. It seems to support some of the same features of a ReplicationController - scale up

3条回答
  •  情书的邮戳
    2021-02-05 00:44

    The functionality of both Replica Controller and Replica Set is quiet the same - they are responsible to make sure that X number of pods with label that is equal to there label selector will be scheduled to different nodes on the cluster.
    (Where X is the value that is specified in the spec.replicas field in the Replica Controller / Replica Set yaml).

    ReplicaSet is a replacement for the Replica controller and supports richer expressions for the label selector. You can choose between 4 values of operators In, NotIn, Exists, DoesNotExist - see Set-based requirement.

    A rule of thumb: When you see Replica Controller is mentioned in one the docs or other tutorials - refer to it as ReplicaSet AND consider using Deployment instead.


    There is also a small difference in the syntax between Replica Controller:

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: nginx
    spec:
      replicas: 3
      selector:
        app: nginx
    

    And the ReplicaSet which contains matchLabels field under the selector:

    apiVersion: apps/v1
    kind: ReplicaSet
    metadata:
      name: nginx
    spec:
      replicas: 3
      selector:
        matchLabels: #<-- This was added
          tier: nginx
    

提交回复
热议问题