kubernetes - 部署文件错误,但找不到从哪里发出
问题描述
我希望人们可以帮助指出我的部署文件中的问题,当我部署时,我在下面收到错误感谢您的帮助
"Deployment.apps "my-app" is invalid: [spec.template.spec.containers[0].volumeMounts[0].name: Not found: "audioSources", spec.template.spec.containers[0].volumeMounts[1].name: Not found: "authors", spec.template.spec.containers[0].volumeMounts[2].name: Not found: "covers"]"
这是我的部署文件
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-app
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- image: myname/myimage
name: my-app
ports:
- containerPort: 3000
volumeMounts:
- name: audioSources
mountPath: /usr/share/nginx/html/audioSources
- name: authors
mountPath: /usr/share/nginx/html/authors
- name: covers
mountPath: /usr/share/nginx/html/covers
volumes:
- name: audioSources
hostPath:
path: /home/websites/audioSources
- name: authors
hostPath:
path: /home/websites/authors
- name: covers
hostPath:
path: /home/websites/covers
解决方案
这是一个固定的部署:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-app
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- image: myname/myimage
name: my-app
ports:
- containerPort: 3000
volumeMounts:
- name: audio-sources
mountPath: /usr/share/nginx/html/audioSources
- name: authors
mountPath: /usr/share/nginx/html/authors
- name: covers
mountPath: /usr/share/nginx/html/covers
volumes:
- name: audio-sources
hostPath:
path: /home/websites/audioSources
- name: authors
hostPath:
path: /home/websites/authors
- name: covers
hostPath:
path: /home/websites/covers
- 卷应低于
spec
, 与containers
. - 此外,名称
audioSource
更改为audio-source
。
推荐阅读
- python-3.6 - Python3.6 如何逐行阅读并用逗号分隔这些行?
- android - 在单独的 Activity 中将 EditText 输入添加到 ListView
- c# - 从 Web Api 返回 XML
- python-3.x - os.listdir 命令未按正确的存储顺序选择文件
- javascript - 在jquery中访问父第二个孩子
- regex - 如何在 Crystal lang 中将 .match 的结果作为字符串值访问
- python-3.x - python 请求 SSLError 与 Heroku 设置
- flask - Flask 服务于 Vue.js 包文件。更改时重新编译?
- jquery - 在 Jquery 中返回元素
- javascript - 将范围输入转换为 int 或 Format 以返回美元