The "" is invalid: : spec.template.spec.volumes.userData in body is a forbidden property

9/6/2019

I'm new to kubernetes and trying to deploy VM using Kubernetes and using this YAML. But when I do oc create -f <yaml_link_above>, I get an error as

The "" is invalid: : spec.template.spec.volumes.userData in body is a forbidden property

I don't see any problem with the formatting with the YAML or whatsoever, maybe I'm missing anything?.

-- Rajat Singh
kubernetes
yaml

2 Answers

9/7/2019

I believe you have an indentation error:

---
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 
-- Rico
Source: StackOverflow

9/11/2019

It seems that your Dynamic Provisioning doesn't work properly. Follow these steps dynamics-provisioning-ceph to configure Ceph RBD Dynamic Storage Class.

Then check if pvc is created properly. After all apply your VM config file.

Here are useful documentations: hardware-configuration, disk-volumes.

-- MaggieO
Source: StackOverflow