Replica Set

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Replication Controller

mumshad mannambeth
High Availability

POD POD POD


POD
Replication Controller
Replication Controller

Node Node
Load Balancing & Scaling

POD POD POD POD

Replication Controller Repl cation Controller


i

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

> kubectl get replicationcontroller


NAME DESIRED CURRENT READY AGE
myapp-rc 3 3 3 19s
replicas: 3
> kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-rc-4lvk9 1/1 Running 0 20s
myapp-rc-mc2mf 1/1 Running 0 20s
myapp-rc-px9pz 1/1 Running 0 20s
replicaset-definition.yml pod-definition.yml
apiVersion: apps/v1 apiVersion: v1
kind: ReplicaSet kind: Pod
metadata:
error: unable to recognize "replicaset-
name: myapp-repl icaset metadata:
labels: definition.yml": no matches for /,name: myapp-pod
Kind=ReplicaSet
app: myapp labels:
type: front-end app: myapp
type: front-end
spec:
template: spec:
containers:
- name: nginx-container
image: nginx

POD
• > kubectl create –f replicaset-definition.yml
replicaset "myapp-replicaset" created

> kubectl get replicaset


NAME DESIRED CURRENT READY AGE
myapp-replicaset 3 3 3 19s
replicas: 3 > kubectl get pods
selector: NAME READY STATUS RESTARTS AGE
matchLabels: myapp-replicaset-9ddl9 1/1 Running 0 45s
myapp-replicaset-9jtpx 1/1 Running 0 45s
type: front-end myapp-replicaset-hq84m 1/1 Running 0 45s
Labels and Selectors
replicaset-definition.yml pod-definition.yml
selector:
metadata:
matchLabels:
name: myapp-pod
tier: PO
PO
POD tier: front-end labels:
PO
front-end D
D D
PO tier: front-end
D

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 get replicaset

> kubectl delete replicaset myapp-replicaset *Also deletes all underlying PODs
> kubectl replace -f replicaset-definition.yml

> kubectl scale --replicas=6 -f replicaset-definition.yml


Deployment

mumshad mannambeth
Deployment v1 v2

POD POD POD POD POD POD POD POD POD

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

NAME DESIRED CURRENT READY AGE


rs/myapp-deployment-6795844b58 3 3 3 9h

NAME READY STATUS RESTARTS AGE


po/myapp-deployment-6795844b58-5rbjl 1/1 Running 0 9h
po/myapp-deployment-6795844b58-h4w55 1/1 Running 0 9h
po/myapp-deployment-6795844b58-lfjhv 1/1 Running 0 9h

You might also like