Virtual Machines Instances

The VirtualMachineInstance type conceptionally has two parts:

  • Information for making scheduling decisions

  • Information about the virtual machine API

Every VirtualMachineInstance object represents a single running virtual machine instance.

API Overview

With the installation of KubeVirt, new types are added to the Kubernetes API to manage Virtual Machines.

You can interact with the new resources (via kubectl) as you would with any other API resource.

VirtualMachineInstance API

Note: A full API reference is available at https://kubevirt.io/api-reference/.

Here is an example of a VirtualMachineInstance object:

  1. apiVersion: kubevirt.io/v1
  2. kind: VirtualMachineInstance
  3. metadata:
  4. name: testvmi-nocloud
  5. spec:
  6. terminationGracePeriodSeconds: 30
  7. domain:
  8. resources:
  9. requests:
  10. memory: 1024M
  11. devices:
  12. disks:
  13. - name: containerdisk
  14. disk:
  15. bus: virtio
  16. - name: emptydisk
  17. disk:
  18. bus: virtio
  19. - disk:
  20. bus: virtio
  21. name: cloudinitdisk
  22. volumes:
  23. - name: containerdisk
  24. containerDisk:
  25. image: kubevirt/fedora-cloud-container-disk-demo:latest
  26. - name: emptydisk
  27. emptyDisk:
  28. capacity: "2Gi"
  29. - name: cloudinitdisk
  30. cloudInitNoCloud:
  31. userData: |-
  32. #cloud-config
  33. password: fedora
  34. chpasswd: { expire: False }

This example uses a fedora cloud image in combination with cloud-init and an ephemeral empty disk with a capacity of 2Gi. For the sake of simplicity, the volume sources in this example are ephemeral and don’t require a provisioner in your cluster.

Additional Information