A replica count is the desired number of pod copies that a workload should maintain. In a ReplicaSet, Kubernetes creates that many pods from the Pod template and works to retain the same number. section 14.1.1
Declaring five replicas
A ReplicaSet manifest can set `spec.replicas` to `5`. Applying it creates five pods from the template. If matching pods already exist, the ReplicaSet can adopt them and create only the additional pods needed to reach five. section 14.1.1 section 14.1.2
Table 14.1 The main fields in the ReplicaSet specification
|
Field name
|
Description
|
|---|---|
replicas
|
The desired number of replicas. When you create the ReplicaSet object, Kubernetes creates this number of pods from the Pod template. The same number of pods is retained until you delete the ReplicaSet.
|
selector
|
The label selector contains either a map of labels in the
matchLabels subfield or a list of label selector requirements in the
matchExpressions subfield. Pods that match the label selector are considered part of this ReplicaSet.
|
template
|
The Pod template for the ReplicaSet’s pods. When a new pod needs to be created, the object is created using this template.
|
Use the ReplicaSet specification table to distinguish the replica count from the selector that identifies managed pods and the template that creates them. section 14.1.1
Inspect and change the desired count with kubectl:
- `kubectl get rs kiada` displays desired, current, and ready replica counts, allowing the configured target to be compared with observed status. section 14.1.2
- Change a ReplicaSet's count to scale it. For example, `kubectl scale rs kiada --replicas 7` raises the desired count. section 14.2 section 15.1.2
- For a Deployment, change the Deployment's `replicas` field or run `kubectl scale deploy kiada --replicas 5`; its controller scales the underlying ReplicaSet. section 15.1.2
- Avoid scaling a ReplicaSet owned by a Deployment directly: the Deployment controller can restore its count to the Deployment's configured value. section 15.1.2

