Professional Documents
Culture Documents
Replica Set
Replica Set
Replica Set
mumshad mannambeth
High Availability
Node Node
Load Balancing & Scaling
Node Node
• Replication Controller Replica Set
rc-definition.yml pod-definition.yml
apiVersion: v1 apiVersion: v1
kind: ReplicationController kind: Pod
metadata: Replication Controller
name: myapp-rc metadata:
labels: name: myapp-pod
app: myapp labels:
type: front-end app: myapp
type: front-end
spec: Replication Controller
template: spec:
containers:
POD - name: nginx-container
image: nginx
POD
• > kubectl create –f rc-definition.yml
POD replicationcontroller “myapp-rc” created
POD
• > kubectl create –f replicaset-definition.yml
replicaset "myapp-replicaset" created
PO PO
D D
PO PO PO PO
D D D D
POD tier: front-end POD tier: front-end
PO PO
D D
PO PO
PO D D
D PO
PO D
D PO PO
PO D D
D
PO
D
replicaset-definition.yml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
labels:
app: myapp POD tier: front-end
type: front-end
spec:
template:
metadata:
name: myapp-pod
POD POD
labels: tier: front-end tier: front-end
app: myapp
type: froTnetm-eplnadte
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end
Scale replicaset-definition.yml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
labels:
app: myapp
type: front-end
> kubectl replace -f replicaset-definition.yml
spec:
template:
metadata:
> kubectl scale -–replicas=6 –f replicaset-definition.yml
name: myapp-pod
labels:
> kubectl scale -–replicas=6 replicaset myapp-replicaset
app: myapp
type: front-end
spec:
containers:
TYPE NAME
- name: nginx-container
image: nginx
replicas: 6
3
selector:
matchLabels:
type: front-end
commands
> kubectl create –f replicaset-definition.yml
> kubectl delete replicaset myapp-replicaset *Also deletes all underlying PODs
> kubectl replace -f replicaset-definition.yml
mumshad mannambeth
Deployment v1 v2
Replica Set
Deployment
deployment-definition.yml
apiVersion: apps/v1
Definition kind:
ReDeplplicoyamSeentt
metadata:
name: myapp-deployment
labels:
app: myapp
> kubectl create –f deployment-definition.yml type: front-end
deployment "myapp-deployment" created spec:
template:
> kubectl get deployments metadata:
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE name: myapp-pod
myapp-deployment 3 3 3 3 21s labels:
app: myapp
> kubectl get replicaset type: front-end
NAME DESIRED CURRENT READY AGE
spec:
containers:
myapp-deployment-6795844b58 3 3 3 2m
- name: nginx-container
image: nginx
> kubectl get pods
NAME READY STATUS RESTARTS AGE
replicas: 3
myapp-deployment-6795844b58-5rbjl 1/1 Running 0 2m selector:
myapp-deployment-6795844b58-h4w55 1/1 Running 0 2m matchLabels:
myapp-deployment-6795844b58-lfjhv 1/1 Running 0 2m
type: front-end
commands
> kubectl get all
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/myapp-deployment 3 3 3 3 9h