Untitled

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

***********************************************************************************

****************
*
*
* EXERCISE: ReplicaSet | Kubernetes
*
*
*
* Author: Srinath Challa | Kubernetes SME | Udemy
*
*
*
* Connect me on:
*
* --------------
*
* https://www.udemy.com/user/srinathchalla/
*
* https://www.linkedin.com/in/srinathchalla/
*
* https://www.youtube.com/srinathchalla
*
*
*
* Reference:
*
* ----------
*
* https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/
*
* https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#how-a-
replicaset-works *
***********************************************************************************
****************

In this Exercise:
----------------
You will deploy the sample ReplicaSet, then Validate, Scale, Edit and Cleanup.

PRE-REQ:
--------
a. To successfully finish this exercise, It is important to go through ReplicaSet
Concept and Demo videos in this series.
b. You can refer to Kuberenetes Docs for help when needed.

***********************************************************************************
****************

STEP-1: Create ReplicaSet:


--------------------------
Write the ReplicaSet YAML file with below configuration and Deploy it using kubectl
apply command.

Container Image: redis


ReplicaSet Name: redis-rs
Replicas: 3
# backend.yaml
apiVersion: apps/v1
kind: ReplicaSet
# backend.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: redi-rs
labels:
app: database
tier: backend
spec:
replicas: 3
selector:
matchLabels:
tier: backend
template:
metadata:
labels:
tier: backend
spec:
containers:
- name: gb-redisworker
image: gcr.io/google-samples/gb-redisworker:v1

***********************************************************************************
****************

STEP-2: Validate ReplicaSet (rs) and Pods:


------------------------------------------

a. Display "redis-rs" replicaset and ensure "Desired, Current, Read" count is 3


kubectl get rs -o wide

b. Display the complete details of "redis-rs" by running "..describe replicaset.."


command
kubectl describe rs backend

c. Print the labels of "redis-rs" ReplicaSet.


kubectl get rs backend --show-labels

c. Display the Pods which are created by this ReplicaSet


kubectl get pods

d. Ensure, "redis-rs" replicaset creates exact 3 three replicas


kubectl get pods

c. Identify on which worker nodes these Pods are scheduled


kubectl get pods -o wide

***********************************************************************************
****************

STEP-3: Edit the ReplicaSet


---------------------------

a. Edit the "redis-rs" ReplicaSet and update the replica count from 3 to 5.
kubectl edit rs redis-rs

b. Display the "redis-rs" replicaSet and ensure "Desired, Current, Ready" is 5.


kubectl get rs -o wide

c. Display the Pods and Ensure two extra Pods are created. Total 5 Pods related to
"redis-rs" should be "Running"
kubectl get pods -o wide

***********************************************************************************
****************

STEP-4: Delete the ReplicaSet:


------------------------------

a. Delete the ReplicaSet.


kubectl delete rs redis-rs

b. Display the ReplicaSet and Ensure "redis-rs" replicaSet is deleted.


Kubectl get rs

c. Display Pods and Ensure "redis-rs" related Pods are deleted.


Kubectl get pods -w

***********************************************************************************
****************

You might also like