DEV Community

Cover image for #035 Kubernetes - Replicasets Lab
Omar
Omar

Posted on

#035 Kubernetes - Replicasets Lab

Introduction

this is part 35 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.


Lab

replica-yml

In last part we talk about what every part mean(go check it :) ).
Yaml have a specific conditions like : case sensitive , also don't use tabs use spaces to align them , I use vim he auto do those stuff for me . Also they are not order sensitive so you can define thing before another. It's like python if you work with it before it's block and aligned so when it start it should be in the same level where it ends so you should align every thing.
Template is the same from last pod lab .
app_033
we can see the template is the pod it self.
here replicas are 4 so it going to create four pods for us.

pods

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

here our old pods , let's create our replicas.

rep-create

kubectl create -f app_035.yml
Enter fullscreen mode Exit fullscreen mode

now we have our replicas created here.
let's get the pods
get2

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

he generate 3 pods with random ID with it (ex: -2jxjd) , but wait we say 4 not 3! yes he take our old pod as 1 of them.
now let's delete them 3:)

deleted

kubectl delete pods first-api-dec myapp-replicaset-2jxjd myapp-replicaset-m4k2f myapp-replicaset-xqvmk
Enter fullscreen mode Exit fullscreen mode

here maybe the names will vary for you so just copy paste them.
immortal
We can as soon we delete them the replicaset create new fresh pods for us, we can also see that the names are now different also there age is few seconds.


Get replicasets

To get our created replicasets we use this command
replicasets
. Desired are what we specify in the yml file
. Current are the current pods created
. Ready are the pods ready to use
. Age is the age where the replica was created

Top comments (0)