1. Listing DaemonSets in All Namespaces
To begin, determine how many DaemonSets exist across all namespaces in your Kubernetes cluster. Execute the following command:kube-flannel-ds and kube-proxy, both located in the kube-system namespace:
Always verify the namespace of your DaemonSets to ensure proper deployment and troubleshooting.
2. Identifying the Namespace of DaemonSets
TheNAMESPACE column in the output above shows that both DaemonSets are deployed in kube-system. To further validate that no DaemonSets are running in the default namespace, run:
kube-system namespace:
kube-flannel-ds and kube-proxy are the only DaemonSets running in the cluster.
3. Examining Pod Scheduling for Kube-Proxy
To assess on how many nodes the pods managed by thekube-proxy DaemonSet are scheduled, start by reviewing the initial DaemonSet listing:
kube-proxy, the desired, current, and ready counts are all one. For a deeper look into its configuration, run:
kube-proxy pods:
kube-proxy DaemonSet is scheduled on one node, matching the cluster configuration.
4. Inspecting the Kubelet DaemonSet (Kube-Flannel)
To examine the specific image used by thekube-flannel-ds (managed as a DaemonSet by kubelet), run:
kube-flannel-ds uses the CoreOS Flannel image.
Ensuring the correct container image for your networking components is crucial for cluster stability.
5. Deploying a DaemonSet for Logging
In this section, you’ll deploy a DaemonSet for logging using Fluentd and Elasticsearch. There are two common methods to obtain the DaemonSet specification.Option 1: Using an Official Sample from Documentation
Refer to the Kubernetes documentation for a sample DaemonSet YAML. Below is an example configuration:Option 2: Converting a Deployment to a DaemonSet
Since Kubernetes doesn’t offer a direct command for creating a DaemonSet, you can start by generating a deployment manifest in dry-run mode and then convert it. Run:fluentd.yaml file to change the kind from Deployment to DaemonSet and remove the replicas and strategy fields, so it closely resembles:
kube-system namespace:
The example provided represents a basic logging configuration. Be sure to customize resource limits, volume mounts, and other parameters to match your production environment.
This concludes the lab on DaemonSets in Kubernetes. You learned how to list and inspect DaemonSets, examine their node scheduling, and deploy a new DaemonSet specifically for logging purposes. For further details on Kubernetes concepts and best practices, explore the following resources: