kubernetes daemonset在注解更改后不会重新启动

f0ofjuux  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(1)|浏览(108)

我有一个daemonset,Pod从configmap获取配置,所以我想在更新configmap时自动重启daemonset。我在Helm Docs中看到了这一点:https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments所以我最后把这句话写进了我的代码:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-logzio
  namespace: fluentd
  annotations:
    config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
  labels:
    k8s-app: fluentd-logzio
    version: v1
spec:
  selector:
    matchLabels:
      k8s-app: fluentd-logzio
  template:
    metadata:
      labels:
        k8s-app: fluentd-logzio
        version: v1
    [...]

字符串
注解更新成功,但守护进程不会重新启动。是因为这不是部署吗我尝试使用kubectl edit更改部署注解,但它也没有触发重启。

xienkqul

xienkqul1#

您需要将注解放在pod模板上,而不是daemonset上:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-logzio
  namespace: fluentd
  labels:
    k8s-app: fluentd-logzio
    version: v1
spec:
  selector:
    matchLabels:
      k8s-app: fluentd-logzio
  template:
    metadata:
      labels:
        k8s-app: fluentd-logzio
        version: v1
      annotations:
        config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
    [...]

字符串
这样,Pod配置将改变,并且Pod将被重新创建。

相关问题