2017-12-21 21 views
0

私は、単純なnginxをkubernetesにhostvolumesを使って配備しようとしています。Kubernetes unknown fields "volumes"

apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: webserver 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     app: webserver 
    spec: 
     containers: 
     - name: webserver 
     image: nginx:alpine 
     ports: 
     - containerPort: 80 
     volumeMounts: 
     - name: hostvol 
      mountPath: /usr/share/nginx/html 
    volumes: 
    - name: hostvol 
     hostPath: 
     path: /home/docker/vol 

私はそれがkubectl create -f webserver.yaml、それが次のエラーがスロー展開:私はあなたが間違ってインデントを持っていると信じてい

error: error validating "webserver.yaml": error validating data: ValidationError(Deployment.spec.template): unknown field "volumes" in io.k8s.api.core.v1.PodTemplateSpec; if you choose to ignore these errors, turn validation off with --validate=false 

答えて

4

私は次のYAMLを使用しています。 volumesキーはcontainersと同じレベルにする必要があります。

apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: webserver 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     app: webserver 
    spec: 
     containers: 
     - name: webserver 
     image: nginx:alpine 
     ports: 
     - containerPort: 80 
     volumeMounts: 
     - name: hostvol 
      mountPath: /usr/share/nginx/html 
     volumes: 
     - name: hostvol 
     hostPath: 
      path: /home/docker/vol 

詳細は、ドキュメントからthis wordpress exampleをご覧ください。

+0

本当にありがとうございます!それが問題だった –