ReplicaSet is a configuration object in k8s which ensures that specific amount of pods are running at the given time. If any of them fails, then ReplicaSet creates a new one to ensure desired amount of pods.
Pods are matched with ReplicaSet using `ownerReferences`. If those are not set, then it matches ReplicaSet selectors.
ReplicaSet can manage pods that were not created by ReplicaSet.
ReplicaSet YAML Manifest Example:
```
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: MyReplicaSet
labels:
mylabel: test
spec:
replicas: 3
selector:
matchLabels:
appid: 123
template:
metadata:
name: myapp
labels:
appid: 123
specs:
containers:
- name: nginx
image: nginx:latest
```
### See also
1. [[What is Pod in k8s?]]
2. [[What is Horizontal Pod Autoscaler?]]