首页 > 解决方案 > 部署文件错误,但找不到从哪里发出

问题描述

我希望人们可以帮助指出我的部署文件中的问题,当我部署时,我在下面收到错误感谢您的帮助

"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

标签: kubernetesdeployment

解决方案


这是一个固定的部署:

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
  1. 卷应低于spec, 与containers.
  2. 此外,名称audioSource更改为audio-source

推荐阅读