在创建DaemonSet时,您可以使用nodeSelector字段来指定要部署到哪些节点。例如:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: my-daemonset
spec:
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
nodeSelector:
my-label: my-value
containers:
- name: my-container
image: my-image
...
在上面的示例中,我们使用nodeSelector将DaemonSet限制为仅在具有标签“my-label: my-value”的节点上运行。如果要在多个节点上部署DaemonSet,则可以使用多个nodeSelector字段来指定不同的节点选择器。