在不停机的情况下(如部署)更新DaemonSet [英] Update a DaemonSet without downtime like a deployment

查看:542
本文介绍了在不停机的情况下(如部署)更新DaemonSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在任何节点上运行应用程序.每个节点应始终至少有一个实例,但允许更多实例,主要是在更新过程中,以防止该Pod(和节点)停机.

I want to run an app on any node. It should always have at least one instance per node, but more instances are allowed, primarily during an update to prevent downtime of that pod (and node).

Kubernetes部署更新通常通过启动新的pod来工作,并且一旦可用,旧的pod就会终止.太完美了,但就我而言,我需要一个DaemonSet来始终在所有节点上启动特定的应用程序.但是,在更新此DaemonSet时,Kubernetes会一个接一个地杀死一个Pod(即逐个节点),然后然后启动一个新Pod,这意味着在更新过程中的任何给定时间Pod可能没有运行在一个节点上.

Kubernetes deployment updates usually work by launching a new pod, and as soon as it is available the old one is terminated. That's perfect, but in my case I need a DaemonSet to launch a specific app on all nodes at all times. However, when updating this DaemonSet, Kubernetes kills a pod one by one (i.e. node by node) and then launches a new pod, which means that on any given time during an update the pod may not be running on a node.

与Deployment相比,DaemonSet似乎是执行此操作的正确方法,但是在更新DaemonSet时我找不到任何防止停机的方法.有什么办法吗?我还考虑过使用Deployments并手动更新副本数量和antiPodAffinity,这样每个节点只能部署一个Pod,但这有点麻烦.

It seems that DaemonSets are, compared to Deployments, the correct way to do that, but I couldn't find any way to prevent downtime when updating the DaemonSet. Is there any way to do this? I also thought of using Deployments and update a replica amount manuall and antiPodAffinity so only one pod gets deployed per node, but this is kind of hacky.

推荐答案

关于添加此功能的讨论很长.您可以在此处

There was a very long set of discussions about adding this feature. You can see them here and here

长话短说,这实际上是不可能的.您可以尝试在updateStrategy中结合使用maxUnavailable: 0type: rollingUpdate,但是我不认为这是正式支持的.

Long story short, this isn't really possible. You can try and combine maxUnavailable: 0 and type: rollingUpdate in your updateStrategy but I don't think that's formally supported.

示例:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: my-daemonset
  labels:
    service: my-daemonset
spec:
  selector:
    matchLabels:
      service: my-daemonset
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
  template:
    metadata:
      labels:
        service: my-daemonset
    spec:
      containers:
      - name: daemonset-update
        image: my-image:latest

这篇关于在不停机的情况下(如部署)更新DaemonSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆