Problem with daemonset creation on kubernetes cluster

7/17/2020

I am running the following command on the master node, to create a daemonset on a Kubernetes cluster.

$ kubectl apply -f https://k8s.io/examples/controllers/daemonset.yaml

I think it got created successfully because the following message is shown,

daemonset.apps/fluentd-elasticsearch created

But after that when I run,

$ kubectl get daemonsets
No resources found in default namespace

So I tried to recreate the same but this time it shows,

$ kubectl apply -f https://k8s.io/examples/controllers/daemonset.yaml
daemonset.apps/fluentd-elasticsearch unchanged

I don’t understand what is happening here. An explanation would be highly appreciated.

-- Mridul Gain
daemonset
kubernetes

4 Answers

7/17/2020

When you go to the official kubernetes documentation and check this link DaemonSet you will see the namespace of your DaemonSet.

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-elasticsearch
  namespace: kube-system
  labels:
    k8s-app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd-elasticsearch
  template:
    metadata:
      labels:
        name: fluentd-elasticsearch
    spec:
      tolerations:
      # this toleration is to have the daemonset runnable on master nodes
      # remove it if your masters can't run pods
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: fluentd-elasticsearch
        image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
-- O.Man
Source: StackOverflow

7/17/2020

The URL you used to create a daemonset creates a daemon set in kube-system namespace. Instead of viewing the daemonset in the default name space. Use the below command. It will shows all the daemonset along with the namespace where it is running.

Kubectl get ds --all-namespaces 
-- manoj
Source: StackOverflow

7/17/2020

It's getting deployed in kube-system namespace since the deployment yaml has namespace: kube-system

kubectl get daemonsets command shows daemonsets from default namespace and hence it gives No resources found

You need to add -n parameter in the command to check daemonsets created in a specific namespace such as kube-system

kubectl get daemonsets -n kube-system
-- Arghya Sadhu
Source: StackOverflow

7/17/2020

Run

kubectl get daemonsets —all-namespaces -o wide

This will give you all the daemon set present on namespace and on worker nodes

-- Dashrath Mundkar
Source: StackOverflow