Kubernetes 如果部署中的副本数为1,且部署不好,则仍会进行部署,我是否可以更改此行为?
我在玩这个:在我的基础设施中。我有一些需要副本的部署—但我有一些部署只需要部署中的一个副本—但是有一种简单的方法来更改映像版本是非常好的,而且是必需的 因此,我试图了解如果您在仅使用1个副本的部署上运行损坏的更新会发生什么情况—如果我们执行以下操作(从上面的文档中): 如果我们运行Kubernetes 如果部署中的副本数为1,且部署不好,则仍会进行部署,我是否可以更改此行为?,kubernetes,google-cloud-platform,Kubernetes,Google Cloud Platform,我在玩这个:在我的基础设施中。我有一些需要副本的部署—但我有一些部署只需要部署中的一个副本—但是有一种简单的方法来更改映像版本是非常好的,而且是必需的 因此,我试图了解如果您在仅使用1个副本的部署上运行损坏的更新会发生什么情况—如果我们执行以下操作(从上面的文档中): 如果我们运行kubectl create-f nginx deployment.yaml 我们看到3个正常运行的副本 如果我们随后将上述文件从replicas:3更改为replicas:1,并运行apply命令:kubectl a
kubectl create-f nginx deployment.yaml
我们看到3个正常运行的副本
如果我们随后将上述文件从replicas:3
更改为replicas:1
,并运行apply命令:kubectl apply-f nginx deployment.yaml
,我们将看到1个健康的副本
现在-如果我们将image:nginx:1.7.9
更改为类似image:nginx:1.7.9break
-并运行kubectl apply-f nginx部署。yaml
我们会看到如下内容:
$ kubectl get rs
NAME DESIRED CURRENT AGE
nginx-deployment-2035384211 0 0 11m <- this is the first one we created with 3 replicas
nginx-deployment-3257237551 1 1 8m <- this is the broken one we made with 1 replica and a bad image name
nginx-deployment-3412426736 0 0 10m <- this is the 2nd one we created with 1 replica
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-3257237551-od22j 0/1 ImagePullBackOff 0 19s
$kubectl获得rs
姓名当前年龄
nginx-deployment-2035384211 0 0 11m我相信您希望将(默认值为1)设置为0。这应该可以防止Kubernetes在把一个健康的豆荚带上来之前把任何现存的豆荚都取下来maxsupge
仅指定在滚动升级期间,您希望看到部署的POD数量超过所需数量。由于您在第三次部署中只尝试推出一个更新的pod,因此超出默认值1的maxsupge
的增加并没有产生任何影响
另请参见文档中的部分
$ kubectl get rs
NAME DESIRED CURRENT AGE
nginx-deployment-2035384211 0 0 11m <- this is the first one we created with 3 replicas
nginx-deployment-3257237551 1 1 8m <- this is the broken one we made with 1 replica and a bad image name
nginx-deployment-3412426736 0 0 10m <- this is the 2nd one we created with 1 replica
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-3257237551-od22j 0/1 ImagePullBackOff 0 19s