Kubernetes – ReplicaSet Explained
- You have a pod running some applications and users are accessing it.
- If the pod goes down for any reason, then the app is down and needs manual intervention to bring it back online.
- A ReplicaSet’s purpose is to maintain a stable set of replica Pods running at any given time.
- As such, it is often used to guarantee the availability of a specified number of identical Pods.
- Below is a sample ReplicaSet Definition file for your reference.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-repl
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
name: myapp
type: front-end
spec:
containers:
- name: nginx-controller
image: nginx
replicas: 3
selector:
matchlabels:
type: front-end