网页
综合
更新时间 2026-11-13 15:30:59
Building a Basic DaemonSet | Kubernetes
自动蜘蛛
kubernetes.io
正文约 2163 字
This page demonstrates how to build a basic DaemonSet that runs a Pod on every node in a Kubernetes cluster. It covers a simple use case of mounting a file from the host, logging its contents using an init container, and utilizing a pause container.
You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:
A Kubernetes cluster with at least two nodes (one control plane node and one worker node) to demonstrate the behavior of DaemonSets.
In this task, a basic DaemonSet is created which ensures that the copy of a Pod is scheduled on every node. The Pod will use an init container to read and log the contents of /etc/machine-id from the host, while the main container will be a pause container, which keeps the Pod running.
Create a DaemonSet based on the (YAML) manifest:
Once applied, you can verify that the DaemonSet is running a Pod on every node in the cluster:
The output will list one Pod per node, similar to:
You can inspect the contents of the logged /etc/machine-id file by checking the log directory mounted from the host:
Where <pod-name> is the name of one of your Pods.
To delete the DaemonSet, run this command:
This simple DaemonSet example introduces key components like init containers and host path volumes, which can be expanded upon for more advanced use cases. For more details refer to DaemonSet.
Was this page helpful?
Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow. Open an issue in the GitHub Repository if you want to report a problem or suggest an improvement.
© 2026 The Kubernetes Authors | Documentation Distributed under CC BY 4.0
© 2026 Copyright © Kubernetes a Series of LF Projects, LLC. For website terms of use, trademark policy and other project policies please see https://lfprojects.org/policies/
ICP license: 京ICP备17074266号-3
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。