我可以在执行 kubectl scale 部署命令时使用 flags 吗?

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

我有一个小 shell 脚本。它有以下代码片段

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

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

第一个命令是缩小部署,第二个命令是扩大部署。 是否有任何标志/条件 (wait --for=condition=complete) 可用于确保部署按比例缩小和按比例放大?

kubectl scale --help.你没有等待完成标志 可以 运行 以下内容来检查副本推出是否已完成:

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

示例:

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

扩展后检查推出状态,推出状态将阻塞,直到可以推出所需的副本数:

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