K8s DaemonSet stills restart

Im starting with K8s and I have problem with my DaemonSet resource. When I apply it, it goes to Running state, then Completed and then CrashLoopBackOff and then again to running etc. I would like to have all my pods to be in Running state. Here is my manifest:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ds-test
  labels:
    app: busybox-ds
spec:
  selector:
    matchLabels:
      name: busybox-ds
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 3
  template:
    metadata:
      labels:
        name: busybox-ds
    spec:
      containers:
      - name: busybox-ds
        image: busybox

Could somebody tell me what am I doing wrong?

>Solution :

The busybox image just runs sh as its command. If it’s not being interacted with, it immediately exits, and hence why you see your pod go to the Completed state.

You need to have that image run a command that will keep its process running.

Using tail -f /dev/null is a common way to do this. So your manifest would look like:

    spec:
      containers:
      - name: busybox-ds
        image: busybox
        command:
        - tail
        - -f
        - /dev/null

Leave a Reply