3
votes

I'm trying to understand basic Kubernetes concepts but its documentation a bit confusing, as for me.

For example, the Replication Controller is mentioned in the kube-controller-manager.

At the same time, Kubernetes Concepts page says about ReplicaSet object.

And only after some googling I found this post on Medium:

Replication Controllers perform the same function as ReplicaSets, but Replication Controllers are old school. ReplicaSets are the smart way to manage replicated Pods in 2019.

And this is not mentioned anywhere in the official docs.

Can somebody please explain to me about Endpoints and Namespace Controllers?

Are they still "valid" Controllers - or they are also outdated/replaced by some other controller/s?

2

2 Answers

3
votes

Replica Controller Vs Replica Set

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.


Regarding Endpoints and Namespace Controllers

The K8S control plane contains multiple controllers - each controller watches a desired state of the resource that it responsible for (Pods, Endpoints, Namespaces etc') via an infinite control loop - also called Reconciliation Loop.

When a change is made to the desired state (by external client like kubectl) the reconciliation loop detects this and attempts to mutate the existing state in order to match the desired state.

For example, if you increase the value of the replicas field from 3 to 4, the ReplicaSet controller would see that one new instance needs to be created and will make sure it is scheduled in one of the nodes on the cluster. This reconciliation process applies to any modified property of the pod template.

K8S supports the following controllers (at least those which I'm familiar with):

1 )  ReplicaSet controller.

2 )  DaemonSet controller.

4 )  Job controller.

5 )  Deployment controller.

6 )  StatefulSet controller.

7 )  Service controller.

8 )  Node controller.

9 )  Endpoints controller.  # <---- Yes - its a valid controller.

10 ) Namespace controller.  # <---- Yes - its a valid controller.

11 ) Serviceaccounts controller.

12 ) PersistentVolume controller.

13 ) More?

All resides in the control plane under a parent unit which is called the 'Controller Manager'.


Additional point

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
1
votes

replication controllers are deprecated and is not recommended any more. Use ReplicaSets instead.

With ReplicaSet you define number of replicas you want to run for a specific application or a service. You would have those many replicas running at any point of time in the kubernetes cluster. It is taken care by ReplicaSet controller.