沪ICP备2021032517号-1

Kubernetes滚动更新及健康检查

  |   0 评论   |   0 浏览

滚动更新

rollingUpdate

spec:
  strategy:
    rollingUpdate:  ##由于replicas为3,则整个升级,pod个数在2-4个之间
      maxSurge: 1      #滚动升级时会先启动1个pod
      maxUnavailable: 1 #滚动升级时允许的最大Unavailable的pod个数

maxSurge、maxUnavailable 值可设为百分比

minReadySeconds

spec:
  minReadySeconds: 30      #滚动升级时30s后认为该pod就绪再接入service

Liveness 和 Readiness

两种探测的配置方法完全一样,支持的配置参数也一样。不同之处在于探测失败后的行为:

Liveness 探测是重启容器。

Readiness 探测则是将容器设置为不可用,不接收 Service 转发的请求。

具体参数选项

  • httpGet:对应HTTPGetAction对象,属性包括:host、httpHeaders、path、port、scheme
  • initialDelaySeconds:容器启动后开始探测之前需要等多少秒,如应用启动一般30s的话,就设置为 30s
  • periodSeconds:执行探测的频率(多少秒执行一次)。默认为10秒。最小值为1。
  • successThreshold:探针失败后,最少连续成功多少次才视为成功。默认值为1。最小值为1。
  • failureThreshold:最少连续多少次失败才视为失败。默认值为3。最小值为1。
  • timeoutSeconds:探测的超时时间,默认 1s,最小 1s
  • tcpSocket:对应TCPSocketAction对象,TCPSocket指定端口。尚不支持TCP hook
  • exec:对应ExecAction对象,需要执行的内容

如:

        image:---  
         ---
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /actuator/info
            port: 9999
            scheme: HTTP
          initialDelaySeconds: 40
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 2
        name: test-app-service
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /actuator/instance
            port: 9999
            scheme: HTTP
          initialDelaySeconds: 40
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 2

标题:Kubernetes滚动更新及健康检查
作者:zifuy
地址:https://www.zifuy.cn/articles/2021/08/25/1629862747829.html