windows docker桌面kubernetes中出错

windows docker桌面kubernetes中出错,docker,kubernetes,Docker,Kubernetes,在windows docker桌面上的kubernetes中,当我尝试挂载空目录时,出现以下错误: error: error when retrieving current configuration of: Resource: "/v1, Resource=pods", GroupVersionKind: "/v1, Kind=Pod" Name: "", Namespace: "default" Object: &{map["apiVersion":"v1" "kind":"Pod"

在windows docker桌面上的kubernetes中,当我尝试挂载空目录时,出现以下错误:

error: error when retrieving current configuration of:
Resource: "/v1, Resource=pods", GroupVersionKind: "/v1, Kind=Pod"
Name: "", Namespace: "default"
Object: &{map["apiVersion":"v1" "kind":"Pod" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":""] "namespace":"default"] "spec":map["containers":[map["image":"nginx:alpine" "name":"nginx" "volumeMounts":[map["mountPath":"/usr/share/nginx/html" "name":"html" "readOnly":%!q(bool=true)]]] map["args":["while true; do date >> /html/index.html; sleep 10; done"] "command":["/bin/sh" "-c"] "image":"alpine" "name":"html-updater" "volumeMounts":[map["mountPath":"/html" "name":"html"]]]] "volumes":[map["emptyDir":map[] "name":"html"]]]]}
from server for: "nginx-alpine-emptyDir.pod.yml": resource name may not be empty
错误信息似乎有点不清楚,我找不到发生了什么。 我的yaml配置如下所示:

apiVersion: v1
kind: Pod
spec:
  volumes:
    - name: html
      emptyDir: {}
  containers:
    - name: nginx
      image: nginx:alpine
      volumeMounts:
        - name: html
          mountPath: /usr/share/nginx/html
          readOnly: true
    - name: html-updater
      image: alpine
      command: ["/bin/sh", "-c"]
      args:
        - while true; do date >> /html/index.html; sleep 10; done
      volumeMounts:
        - name: html
          mountPath: /html 


忘记添加元数据名称

metadata:
  name: empty-dir-test
更改后的代码为:

apiVersion: v1
kind: Pod
metadata:
  name: empty-dir-test
spec:
  volumes:
    - name: html
      emptyDir: {}
  containers:
    - name: nginx
      image: nginx:alpine
      volumeMounts:
        - name: html
          mountPath: /usr/share/nginx/html
          readOnly: true
    - name: html-updater
      image: alpine
      command: ["/bin/sh", "-c"]
      args:
        - while true; do date >> /html/index.html; sleep 10; done
      volumeMounts:
        - name: html
          mountPath: /html