kubectl rollout status - 命令何时完成?

kubectl rollout status - When the command complete?

目前我正在我的管道中使用它

kubectl apply -f deployment.yaml && kubectl rollout status -f deployment.yaml

在 yaml 中使用这个

      readinessProbe:
        tcpSocket:
          port: 90
        initialDelaySeconds: 120
        periodSeconds: 10
        timeoutSeconds: 10
        failureThreshold: 1
        successThreshold: 1
      livenessProbe:
        tcpSocket:
          port: 90
        initialDelaySeconds: 120
        periodSeconds: 20
        timeoutSeconds: 2
        failureThreshold: 1
        successThreshold: 1

对我来说,kubectl rollout 是 运行 很长一段时间,阻塞了部署管道。来自 the documentation

By default 'rollout status' will watch the status of the latest rollout until it's done

我的问题:

1/ 哪些操作有助于部署“直到完成”(资源创建、资源拆卸?...)

2/ readinessProbe 和 livenessProbe 是否对部署时间有贡献

此标准是 in the kubectl source。如果满足以下条件,则部署“完成”:

  • 还没超时
  • 它的更新副本数至少是它的期望副本数(每个新 pod 都已创建)
  • 它的当前副本数最多是它的更新副本数(每个旧的 pod 都被销毁了)
  • 它的可用副本数至少是它的更新副本数(每个新 pod 都是 运行)

您可以使用 kubectl get deployment -wkubectl get pod -w 实时观看部署实际发生的情况; kubectl get -w 选项监视给定的资源并在它们发生变化时打印出一个新行。您将看到以下顺序发生(使用默认部署设置,“小型”部署一次一个):

  1. 创建了一个新的 pod
  2. 新 pod 通过其探测并准备就绪
  3. 旧 pod 已终止
  4. 旧的pod实际退出并被删除

所以为了 kubectl rollout status deployment/... 完成,所有这些步骤都必须发生 – 创建新的 pods,新的 pods 全部通过健康检查,旧的 pods 是destroyed – 对于部署中的每个副本。