Managing Pods with ReplicaSets 

A ReplicaSet is a term for API objects in Kubernetes that refer to Pod replicas. The idea is to be able to control a set of Pods' behaviors. The ReplicaSet ensures that the Pods, in the amount of a user-specified number, are running all the time. If some Pods in the ReplicaSet crash and terminate, the system will recreate Pods with the original configurations on healthy nodes automatically, and keep a certain number of processes continuously running. While changing the size of set, users can scale the application out or down easily. According to this feature, no matter whether you need replicas of Pods or not, you can always rely on ReplicaSet for auto-recovery and scalability. In this recipe, you're going to learn how to manage your Pods with ReplicaSet:

ReplicaSet and their Pods on two nodes

The ReplicaSet usually handles a tier of applications. As you can see in the preceding diagram, we launch a ReplicaSet with three Pod replicas. Some mechanism details are listed as follows:

  • The kube-controller-manager daemon helps to maintain the resource running in its desired state. For example, the desired state of ReplicaSet in the diagram is three Pod replicas.
  • The kube-scheduler daemon on master, the scheduler of Kubernetes, takes charge of assigning tasks to healthy nodes.
  • The selector of the ReplicaSet is used for deciding which Pods it covers. If the key-value pairs in the Pod's label include all items in the selector of the ReplicaSet, this Pod belongs to this ReplicaSet. As you will see, the diagram shows three Pods are under the charge of the ReplicaSet. Even though Pod 2 has a different label of env, it is selected since the other two labels, role and project, match the ReplicaSet's selector.
ReplicationController? ReplicaSet? 
For experienced Kubernetes players, you may notice ReplicaSet looks quite similar to the ReplicationController. Since version 1.2 of Kubernetes, in order to concentrate on different features, the ReplicationController's functionality has been covered by ReplicaSet and Deployment. ReplicaSet focuses on the Pod replica, keeping certain Pods running in healthy states. On the other hand, Deployment is a higher-level API, which can manage the ReplicaSet, perform application rolling updates, and expose the services. In Kubernetes v1.8.3, users can still create replication controllers. However, using Deployment with ReplicaSet is more recommended because these are up to date and have finer granularity of configuration.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.21.239