正常yaml:
代码语言:javascript复制apiVersion: apps/v1
kind: DaemonSet
metadata:
name: daemonset-example
labels:
app: daemonset
spec:
selector:
matchLabels:
name: daemonset-example
template:
metadata:
labels:
name: daemonset-example
spec:
containers:
- name: daemonset-example
image: nginx:1.17
imagePullPolicy: IfNotPresent
注意:第三行的metadata.name的名字一定要和第九行的matchLabels.name名字相同,否则报以下错误:
代码语言:javascript复制[root@k8s-master ~]# kubectl apply -f daemonset.yaml
The DaemonSet "daemonset-example" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"name":"daemonset-example"}: `selector` does not match template `labels`