What does ReplicaSet mean?
This article introduces what ReplicaSet means, the content is very detailed, interested friends can use it for reference, I hope it can be helpful to you.
ReplicaSet is similar to ReplicationController in that it is also used to manage a class of Pod objects to ensure that the number of Pod copies is always maintained at the expected value.
ReplicaSet configuration
A simple ReplicaSet configuration is as follows:
ApiVersion: apps/v1kind: ReplicaSetmetadata: name: replicaset-runs-podspec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers:-name: nginx image: nginx:1.19.0
This ReplicaSet configuration ensures that there are always three Pod replicas with the app: nginx tag running in the cluster, and if the number of replicas is less than 3, the Pod is created using the Pod template spec.template, and if the number of replicas is more than 3, the extra copies are deleted.
The three core elements of the ReplicaSet configuration are as follows:
Spec.selector is used to find the Pod that exists in the cluster
Spec.replicas is used to specify the expected number of Pod copies
Spec.template is used to specify the Pod template that will be used to create a new Pod when the number of copies is insufficient.
The difference between ReplicaSet and ReplicationController
Both ReplicationController and ReplicaSet belong to Pod controller, and their original design intention is almost the same. Both of them are designed to ensure that the number of Pod replicas of the specified type is maintained at the expected value, and ReplicationController appears earlier than ReplicaSet, so why design another ReplicaSet when there is already ReplicationController? What's the difference between the two?
The main difference between the two is the tag selector. ReplicaSet has a more advanced tag selector, ReplicationController only supports the old tag selector, and ReplicaSet supports not only the old selector, but also the new selector.
The selectors supported by ReplicationController are called Equality-based selectors, which are based on equivalents:
Selector map[string] string
ReplicaSet supports not only Equality-based selectors, but also Set-based selectors, that is, collection-based selectors:
Type LabelSelector struct {MatchLabels map[string] string MatchExpressions [] LabelSelectorRequirement}
When the ReplicationController feature evolved to V1, there is no support for Set-based selector, and Kubernetes hopes to introduce a Pod controller that supports Set-based selector. In order not to break API compatibility, it has no choice but to introduce a ReplicaSet controller to replace ReplicationController.
About what ReplicaSet means to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.