<aside> ⛔ Newer and better way to manage replicated pods in K8s than Replication Controllers
</aside>
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: httpd-frontend
labels:
name: frontend
spec:
replicas: 3
selector:
matchLabels:
name: frontend
template:
metadata:
labels:
name: frontend
spec:
containers:
- name: httpd
image: httpd:2.4-alpine
template
→ metadata
and spec
from the config file for the pod (required to spawn new pods if any of them goes down)replicas
→ how many replicas to maintainselector
which allows the replica set to select pods that match specific labels. This way the replica set can manage pods that were not created by it.k apply -f config.yaml
kubectl
- k scale replicaset my-replicaset --replicas=2