CrashLoopBackOff时如何自动停止滚动更新?

时间:2018-08-31 19:05:18

标签: kubernetes google-kubernetes-engine

我使用Google Kubernetes Engine,并故意在代码中输入错误。我希望滚动更新在发现状态为const mongoose = require ('mongoose'); var url = "mongodb://localhost:27017/db1" //connect to mongodb mongoose.connect(url) var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', function() { // we're connected! var Schema = mongoose.Schema; var Person = mongoose.model('Person', yourSchema); // find each person with a last name matching 'Ghost', selecting the `name` and `occupation` fields Person.findOne({ 'name.last': 'Ghost' }, 'name occupation', function (err, person) { if (err) return handleError(err); // Prints "Space Ghost is a talk show host". console.log('%s %s is a %s.', person.name.first, person.name.last, person.occupation); }); }); 时会停止,但是不是。

在此page中,他们说..

  

Deployment控制器将自动停止错误的推出,并且   将停止按比例扩大新的ReplicaSet。这取决于   您拥有的rollingUpdate参数(特别是maxUnavailable)   指定。

但这并没有发生,仅当状态为CrashLoopBackOff时?

下面是我的配置。

ImagePullBackOff

P.S。我已经阅读了活跃性/就绪性探针,但是我认为它不能停止滚动更新吗?还是它?

3 个答案:

答案 0 :(得分:1)

结果是,我只需要设置minReadySeconds,当新的副本集的状态为CrashLoopBackOff或类似Exited with status code 1时,它将停止滚动更新。因此,现在旧的copysetSet仍然可用并且未更新。

这是新的配置。

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: volume-service
  labels:
    group: volume
    tier: service
spec:
  replicas: 4
  minReadySeconds: 60
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 2
      maxSurge: 2
  template:
    metadata:
      labels:
        group: volume
        tier: service
    spec:
      containers:
      - name: volume-service
        image: gcr.io/example/volume-service:latest

谢谢大家的帮助!

答案 1 :(得分:0)

您引用的解释是正确的,这意味着新的copySet(出现错误的那个)将不会继续执行,但是会在其前进到maxSurge + {{1}的过程中停止}数。而且旧的copySet也将出现。

这是我尝试的示例:

maxUnavailable

这些是结果:

spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1

我的新副本集将仅启动2个新Pod(NAME READY STATUS RESTARTS AGE pod/volume-service-6bb8dd677f-2xpwn 0/1 ImagePullBackOff 0 42s pod/volume-service-6bb8dd677f-gcwj6 0/1 ImagePullBackOff 0 42s pod/volume-service-c98fd8d-kfff2 1/1 Running 0 59s pod/volume-service-c98fd8d-wcjkz 1/1 Running 0 28m pod/volume-service-c98fd8d-xvhbm 1/1 Running 0 28m NAME DESIRED CURRENT READY AGE replicaset.extensions/volume-service-6bb8dd677f 2 2 0 26m replicaset.extensions/volume-service-c98fd8d 3 3 3 28m 中的1个插槽和maxUnavailable中的1个插槽)。

旧的副本集将继续运行3个Pod(4-1 maxSurge)。

您在unAvailable部分中设置的两个参数是关键点,但是您也可以使用诸如rollingUpdatereadinessProbelivenessProbe,{{ 1}}。

对于他们来说,here参考。

答案 2 :(得分:0)

我同意@ Nicola_Ben -我也将考虑更改为以下设置:

      <Form
        layout="vertical"
        size="medium"
       >
             <Input.Group compact>
                 <Form.Item label={product.productName + " : "} />
                 <Input addonBefore={"TestLabel"}  style={{ width:"34%" }} />
             </Input.Group>
      </Form>

或者甚至将spec: replicas: 4 strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 <----- I want at least (4)-[1] = 3 available pods. maxSurge: 1 <----- I want maximum (4)+[1] = 5 total running pods. 更改为maxSurge
这将帮助我们暴露不太可能出现的无法运行的Pod(就像我们在canary release中所做的那样)。

像@ Hana_Alaydrus 一样,建议设置0很重要。

除此之外,有时我们需要在推出后执行更多操作。
(例如,在某些情况下,新的Pod不能正常运行,但在容器内运行的进程没有崩溃)。

有关常规调试过程的建议:

1)首先,使用以下命令暂停部署: minReadySeconds

2)调试相关的pod并决定如何继续(也许我们可以继续使用新版本,也许没有)。

3)我们将不得不使用以下内容恢复部署:kubectl rollout pause deployment <name>,因为即使我们决定使用kubectl rollout resume deployment <name>命令(4.B)返回到先前的版本,我们也需要首先{{1} }推出。

4.A)继续使用新版本。

4.B)使用undo返回上一版本。


以下是可视摘要(在内部单击以查看评论):

enter image description here

相关问题