ConscriptMR
ConscriptMR

Reputation: 776

kubernetes daemonset won't restart after annotation change

i have a daemonset where the pods are getting their configuration from a configmap, so i wanted to automatically restart the daemonset when i update the configmap. i saw this in helm docs: https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments so i ended up putting this in my code:

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
    [...]

the annotation updates successfully but the daemonset won't restart. is it because it's not a deployment? i tried changing deployment annotation using kubectl edit and it also didn't trigger a restart.

Upvotes: 0

Views: 1486

Answers (1)

Chris
Chris

Reputation: 5623

You need to put the annotation on the pod template, not the 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 }}
    [...]

that way the pod config changes and the pods will be recreated.

Upvotes: 3

Related Questions