一直学一直嗨,一直嗨一直学

编写DaemonSet控制器的yaml文件注意事项

正常yaml:

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名字相同,否则报以下错误:

[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`

原文出处:myit -> https://myit.icu/index.php/archives/892/

Tags: