Introduction
this is part 37 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.
Scaling up & down
Scaling is very important because some times we need to scale our replicas , scale here is up or down , let's say the trending calendar has end , and visitors start to drop so we need to scale in this case.
Files for this lab
all the files can be found on the repository of this journey , if you already have it just pull if not clone it. Files can be found here
Imperative scale
We have 2 methods to scale imperative and declarative (explained what is difference before here).
kubectl get replicasets
kubectl get pods
I have 1 replica and 4 pods created by this replica. let's try to scale it:
- imperative (not recommended) :
kubectl scale --replicas=6 replicaset myapp-replicaset
we specify here how many we need , we take 6 as an example to scale up (was 4) . And what we need to scale? replicaset and we pass here name.
as soon when we press enter , we can see 2 new pods are creating.
after few seconds , we see they are now 6 up and running :D
now time to scale down
kubectl scale --replicas=2 replicaset myapp-replicaset
just we decrease the number to 2 We can see that 4 of our pods are terminating. we can see we only have 2 pods running now.
Declarative scale
Declarative is better choice because it save our configurations. I am going to use the app037declarativescaleup.yml here a look at it. All what I do is change the replicas number to 6.
kubectl replace -f app_037_declarative_scale_up.yml
we use replace and -f then location of our file , since we are in the same directory so we pass name directly. Also we need to scale now from 2 to 6 so I am going to use the scale up yml.
We can see 6 pods are now creating. after seconds our pods are up and running.
To scale down do the same but replace with to down file(can be be found on github link)
End
Sorry for not writing daily because this month and half I am very busy , I will continue to do it daily on 09/08/2020.