apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: rs-nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: nginx
The main difference from ReplicationController is that ReplicaSet requires a selector. ReplicaSet can manage pods that are not created during ReplicaSet creation: for example there are a pods created before creation of ReplicaSet.