Deploying two different daemonsets with the same List manifest

1/17/2021

I have a scenario where I need to deploy one pod on every node in my cluster so that it can watch certain behaviour (like, whether the pod gets created, terminated properly or not). Since, I've already one DaemonSet running inside my cluster, I wanted to add one more DaemonSet using the available config to the List resource,

apiVersion: v1
kind: List
metadata:
  name: Daemonset-deploy
  namespace: test-ns
items:
  - kind: DaemonSet
    apiVersion: apps/v1
    metadata:
      name: DaemonSet1
      namespace: test-ns
    spec:
    <add the spec here>
  - kind: DaemonSet
    apiVersion: apps/v1
    metadata:
      name: DaemonSet2
      namespace: test-ns
    spec:
    <add the spec for second daemonset>

I wanted to understand whether this is the correct way to deploy two DaemonSets or not. Since, when I tried deploying the same config, the first DaemonSet came up and running but the second one didn't show up at all.

-- NightOwl19
containers
daemonset
kubernetes
yaml

1 Answer

1/17/2021

you don't need to use list to deploy 2 daemonset. you can just create two differenet daemonset separately. and if you need create your daemonset's pods in specific node you can just create them with the use of spec.template.spec.nodeSelector in your template's spec. ref

here is the example how you are going to create two different daemonset.

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: DaemonSet1
  namespace: test-ns
spec:
    <add the spec here>
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: DaemonSet2
  namespace: test-ns
spec:
    <add the spec for second daemonset>
---
-- Emon46
Source: StackOverflow