1) How many DaemonSets exist in the cluster (all namespaces)?
Run:kube-flannel-dskube-proxy
2) Which namespace are the DaemonSets created in?
Check theNAMESPACE 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:
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:
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 withkubectl 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.- Generate a Deployment YAML for fluentd (dry run):
- Edit
fluentd.yamlto convert the Deployment into a DaemonSet:- Change
kind: Deploymenttokind: DaemonSet. - Remove
replicasand anystrategyfields (DaemonSets do not use them). - Ensure
.spec.selector.matchLabelsmatches.spec.template.metadata.labels. - Add any necessary tolerations, volumes, and volumeMounts to match your cluster’s logging needs.
- Change
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.- Create the DaemonSet from the edited YAML:
- Verify the DaemonSet in the
kube-systemnamespace:
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
- DaemonSet — Kubernetes Concepts
- kubectl create — Kubernetes CLI reference
- Fluentd images and examples: check the image repository used in your environment (for example,
k8s.gcr.io/fluentd-elasticsearchandquay.io/fluentd_elasticsearch/fluentd)