ReplicaSets - recap Flashcards
What is a ReplicaSet
- runs multiple instance of a single pod
- provides high availability
- automates bringing up a single pod
- helps with load balancing and scaling
What’s the difference between a ReplicaSet and Replication Controller
- Similar purpose
- Replication Controller is the older approach and ReplicaSet is newer
How do I create a replication controller
- Create a yaml file with the required fields
- kind: ReplicationController
- spec must include template section
What does template do in YAML config
Tells the ReplicationController how to create more pods with those specifications
How do I create a ReplicaSet
- Create a YAML definition
- apiVersion must be apps/v1
- kind must be ReplicaSet
- spec > template (same as replication controller)
- replicas: number of desired replicas
- selector: helps ReplicaSet identify what pods fall under its control
- matchLabel: matches labels to the ones on the pod template
Why do we need a “selector” in the ReplicaSet YAML definition
Because ReplicaSets can manage pods not created as part of the ReplicaSet (e.g., pods created before the ReplicaSet but which fall under the same selector label)
Which labels have to match in the ReplicaSet YAML definition
select > matchLabels > tier
must match
template > metadata > labels > tier
How do I scale ReplicaSets
- Update the replicas field
- $ k scale –replicas=<number> -f <yaml></yaml></number>
Does running $ k scale <etc> change the YAML definition file</etc>
No. You must also:
* update the yaml
* $ k delete replicaset <name>
* $ k replace 0f <updated></updated></name>