“”无效::body中的spec.template.spec.volumes.userData是禁止的属性

时间:2019-09-06 21:15:13

标签: kubernetes yaml

我是kubernetes的新手,并且尝试使用Kubernetes 并使用此 YAML 来部署VM。但是当我这样做   "name": "Metal_2_roughness.jpg", "images": [ { "height": 2048, "createdAt": "2017-08-11T16:14:06.933292", "updatedAt": "2017-08-11T16:14:06.933307", "uid": "ae19ea6db7074248ac4e04b4db971913", "width": 2048, "options": {}, "url": "https://media.sketchfab.com/urls/cbfbf4d275c24eafa51eaf3a6c3c91b9/dist/textures/16fb95f74f4846079a32f15c2be35565/ae19ea6db7074248ac4e04b4db971913.jpeg", "size": 1042057 }, ,我收到错误消息

oc create -f <yaml_link_above>

我没有看到YAML格式的任何问题,或者可能是我遗漏了什么?。

2 个答案:

答案 0 :(得分:1)

您的动态预配置似乎无法正常运行。请按照dynamics-provisioning-ceph的步骤配置Ceph RBD动态存储类。

然后检查是否正确创建了pvc。毕竟,请应用您的VM配置文件。

以下是有用的文档:hardware-configurationdisk-volumes

答案 1 :(得分:0)

我相信您有缩进错误:

---
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  labels:
    kubevirt.io/vm: vm-cirros-datavolume-file
  name: vm-cirros-datavolume-file-new
spec:
  dataVolumeTemplates:
  - metadata:
      creationTimestamp: null
      name: cirros-dv-file
    spec:
      pvc:
        accessModes:
         - ReadWriteOnce
        resources:
          requests:
            storage: 2Gi
        storageClassName: ocsinit-ceph-rbd 
      source:
        registry:
          url: docker://kubevirt/cirros-registry-disk-demo:latest
    status: {}
  running: true
  template:
    metadata:
      labels:
        kubevirt.io/vm: vm-cirros-datavolume-file
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: datavolumedisk1
          - disk:
              bus: virtio
            name: cloudinitdisk
        machine:
          type: ""
        resources:
          requests:
            memory: 64M
      terminationGracePeriodSeconds: 0
      volumes:
      - dataVolume:
          name: cirros-dv-file-new
        name: datavolumedisk1
      - cloudInitNoCloud:
          userData: |    <== add two spaces to userData
            #!/bin/sh
            echo 'printed from cloud-init userdata'
        name: cloudinitdisk