docker - windows 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" "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
推荐阅读
- bash - smbclient 删除文件命令不起作用
- string - 如何在 react.js 中以粗体打印字符串的一部分
- vue.js - 用户已登录后的路由器重定向将不起作用
- firebase - 如何从 Firestore 的 transaction.set() 中获取新文档的 ID?
- ruby-on-rails - 如何建立 has_many、多态、自引用关系
- ros - bash: cd: catkin_ws/src/: 没有这样的文件或目录
- java - 二维数组中所有岛屿之间的最大总和是多少?必须使用递归
- sorting - awk 数组遍历中的字母数字或“版本排序”
- scala - 如何将变量传递到 DataFrame.selectExpr
- cratedb - 如何保存与 cratedb 中的 last_modified 列不同的 persist_timestamp 列?