ReplicaSets
ReplicaSet : A process that monitors the pods and redeploys if it fails
The labels in the RS spec section search for pods with those labels, so it matches the template/labels section and not the metadata/labels section!
tip
ReplicaSets can also manage pods that were not created under the replicaset itself.
Template
# tip! Are you sure you don't want a deployment ?
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: ${RESOURCE_NAME}
namespace: default
labels: &app_labels
name: ${RESOURCE_NAME}
spec:
selector:
matchLabels:
<<: *app_labels
replicas: 1
template:
metadata:
name: ${RESOURCE_NAME}
labels:
<<: *app_labels
spec:
containers:
- name: ${RESOURCE_NAME}
image: localhost:30000/${RESOURCE_NAME}:latest
Replication Controller
Replication Controller is older technology, ReplicaSet is newer standard. Both do similar tasks.