Home > database >  Can I use flags , while performing the kubectl scale deployment commands?
Can I use flags , while performing the kubectl scale deployment commands?

Time:05-04

I am having a small shell script . it has the following snippet of code

kubectl scale deployment sample1 --replicas=0 -n sb1

kubectl scale deployment sample1 --replicas-3 -n sb1

The first command is scale down my deployment and the second command is to scale up . is there any flags /conditions (wait --for=condition=complete) that I can use to ensure the deployment is scaled down and scaled up ?

CodePudding user response:

There is no wait for completion flag in kubectl scale --help. You may run the following to check if the replica rollout is completed:

kubectl scale deployment sample1 --replicas 5 && kubectl rollout status deployment/sample1

Example:

kubectl scale deployment sample1 --replicas 5
deployment.apps/sample1 scaled

After scaling check the rollout status, the rollout status will block until the rollout to desired replica count is available:

kubectl rollout status deployment/sample1
Waiting for deployment "sample1" rollout to finish: 0 of 5 updated replicas are available...
Waiting for deployment "sample1" rollout to finish: 1 of 5 updated replicas are available...
Waiting for deployment "sample1" rollout to finish: 3 of 5 updated replicas are available...
Waiting for deployment "sample1" rollout to finish: 4 of 5 updated replicas are available...
deployment "sample1" successfully rolled out

kubectl get deploy
NAME                READY   UP-TO-DATE   AVAILABLE   AGE
sample1   5/5     5            5           2m40s
  • Related