ReplicaSet Exercise-01

If you are new to the ReplicaSet YAML file click here

i) Create a replica set YAML with 3 pods.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3

ii) Deploy Replicaset YAML file

$ kubectl apply -f <FILENAME.YAML> or 
$ kubectl create -f <FILENAME.YAML>

iii) Display the replica set

$ kubectl get rs
$ kubectl get rs <RS-NAME>

iv) Print wide output of the replica set

$ kubectl get rs -o wide

v) Print replica set in particular NameSpace (replica set are deployed in default namespace)

$ kubectl get rs <RS-NAME> -n default

vi) Print the replica set to output in YAML/JSON format

$ kubectl get rs <POD-NAME> -o yaml  
$ kubectl get rs <POD-NAME> -o json

vii) Print the replica set labels

$ kubectl get rs --show-labels

viii) Print Pods with a specific label

$ kubectl get rs -l app=guestbook

ix) Print the details description of pods

$ kubectl describe rs <RS-NAME>

x) Scaling the number of pods of the replica set, current we have three pods and we will increase it to 5.

$ kubectl scale rs <RS-NAME> --replicas=[COUNT]

xi) Edit ReplicaSet and change the docker image to nginx.

$ kubectl edit rs <RS-NAME>

Run the kubectl edit rs frontend command and search for image section and change image as nginx.

Test the changes by checking the images

$ kubectl get rs frontend -o wide 

xii) Running operations directly on the YAML file

$ kubectl get –f [FILE-NAME.yaml]
$ kubectl describe –f [FILE-NAME.yaml]
$ kubectl edit –f [FILE-NAME.yaml]
$ kubectl delete –f [FILE-NAME.yaml]
$ kubectl apply –f [FILE-NAME.yaml]
$ kubectl describe –f [FILE-NAME.yaml]
$ kubectl edit –f [FILE-NAME.yaml]
$ kubectl delete  -f replicaset.yaml
$ kubectl apply -f replicaset.yaml

xiii) Delete the replicaset

$ kubectl delete rs <RS-NAME>

--

--

--

DevOps Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Create Flutter Desktop App

TryHackMe: Pyscho Break

TWTW- Week 2, September 2018

How To Learn Any Thing Fast Within A short Period of Time

Java Heap Size Setup and Garbage Collector Working

CS373 Blog Post #3

8 Steps to Become an Outstanding Software Developer

How to become an exceptional software developer

Observability, Part 1: Intro & Postgres-Exporter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bikram

Bikram

DevOps Engineer

More from Medium

Pods YAML Walkthrough

[Workaround] Let's solve the Jenkins slave connection issue with the Jenkins Kubernetes plugin

Adding Windows Node to K8S Cluster and Monitoring

Connect to Azure Kubernetes Service from your local