Skip to main content
In this lesson we inspect existing DaemonSets in the cluster and then create a simple fluentd logging DaemonSet by generating YAML from a Deployment and converting it to a DaemonSet. The steps below reproduce the commands, outputs, and edits needed to complete the lab.

1) How many DaemonSets exist in the cluster (all namespaces)?

Run:
Example output:
From the output above, there are two DaemonSets in the cluster:
  • kube-flannel-ds
  • kube-proxy
Summary table

2) Which namespace are the DaemonSets created in?

Check the NAMESPACE column shown by kubectl get daemonsets --all-namespaces above. Both kube-flannel-ds and kube-proxy are in the kube-system namespace. Select kube-system when prompted in the lab.

3) Which of the following is a DaemonSet?

From the list shown earlier, kube-flannel-ds and kube-proxy are DaemonSets. Other components such as scheduler, coredns, or etcd-master are not DaemonSets (they may be Deployments, static pods, or other controller types).

4) On how many nodes are the pods scheduled by the DaemonSet kube-proxy?

Describe the DaemonSet in the kube-system namespace:
Relevant excerpt (trimmed):
This output shows the DaemonSet is scheduling pods on 1 node. You can verify the cluster has one node with:
Example output:
So, in this cluster kube-proxy has pods scheduled on a single node.

5) What image is used by the pod deployed by the kube-flannel-ds DaemonSet?

Describe kube-flannel-ds:
Relevant excerpt (trimmed):
The kube-flannel container image is quay.io/coreos/flannel:v0.13.1-rc1.

6) Deploy a DaemonSet for fluentd logging

You can author the DaemonSet manifest by hand or generate a resource YAML with kubectl and edit it. One convenient trick when a generator for a DaemonSet is not available is to generate a Deployment manifest and convert it to a DaemonSet by editing the file.
You can generate YAML without creating the resource using --dry-run=client -o yaml. Generate the resource, edit the file to match DaemonSet semantics, and then apply it with kubectl create -f or kubectl apply -f.
Follow these steps:
  1. Generate a Deployment YAML for fluentd (dry run):
The generated YAML will look similar to this (trimmed):
  1. Edit fluentd.yaml to convert the Deployment into a DaemonSet:
    • Change kind: Deployment to kind: DaemonSet.
    • Remove replicas and any strategy fields (DaemonSets do not use them).
    • Ensure .spec.selector.matchLabels matches .spec.template.metadata.labels.
    • Add any necessary tolerations, volumes, and volumeMounts to match your cluster’s logging needs.
Warning: Make sure the DaemonSet selector matches the pod template labels exactly; otherwise kubectl will reject the manifest.
If .spec.selector.matchLabels does not match .spec.template.metadata.labels, applying the manifest will fail. Always keep them in sync when converting Deployments to DaemonSets.
After editing, the manifest might look like this example (trimmed for clarity):
(You can extend this manifest with additional volumes, config maps, or node selectors depending on your logging pipeline and cluster topology.)
  1. Create the DaemonSet from the edited YAML:
Example output:
  1. Verify the DaemonSet in the kube-system namespace:
Example output after creation:
Note: In this simple example the newly created elasticsearch DaemonSet (the fluentd logging daemon) may take some time to become READY. Add required volumes, volume mounts, tolerations, and node selectors as appropriate for your cluster and logging pipeline.

References

That completes the lab.

Watch Video