A ReplicaSet keeps a Kubernetes application running at a declared replica count by creating pods from a shared pod template and selecting them through labels. section 3.3.3
Configure the controller around three operational decisions:
- Set apiVersion to apps/v1 and kind to ReplicaSet. section 3.3.3
- Define a pod template containing metadata, labels, the application container, image, and port. section 3.3.3
- Set replicas to the desired count and make selector.matchLabels match the template labels. section 3.3.3
Scaling and replacement
Creating a ReplicaSet with replicas: 3 produces three running pods. Deleting one causes another pod to appear; kubectl scale ReplicaSet joker-replicaset --replicas=4 raises the target to four. section 3.3.3
Listing 3.5 replicaset.yaml: creating a ReplicaSet
apiVersion: apps/v1 #1
kind: ReplicaSet #2
metadata:
name: joker-replicaset #3
labels:
app: fast-api #4
spec:
template: #5
metadata:
name: joker
labels:
app: fast-api #6
spec:
containers:
- name: hello-joker
image: varunmallya/hello-joker:v1
ports:
- containerPort: 8083
replicas: 3 #7
selector:
matchLabels: #8
app: fast-api
Inspect the complete replicaset.yaml manifest, including the pod template, selector, container image, port, and replica count. section 3.3.3




