简体   繁体   中英

Problem with daemonset creation on kubernetes cluster

I am running the following command on the master node, to create a daemonset on a Kube.netes 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.

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

Run

kubectl get daemonsets —all-namespaces -o wide

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

When you go to the official kube.netes 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

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM