Ensure that the VirtualMachineInstance is running if it should be running

It focuses on a 1:1 relationship between the controller instance and a virtual
machine instance. In many ways it is very similar to a
StatefulSet
with spec.replica set to 1.

How to use a VirtualMachine

A VirtualMachine will make sure that a VirtualMachineInstance object with an
identical name will be present in the cluster, if spec.running is set to
true. Further it will make sure that a VirtualMachineInstance will be removed from
the cluster if spec.running is set to false.

Starting and stopping

After creating a VirtualMachine it can be switched on or off like this:

Controller status

Once a VirtualMachineInstance is created, its state will be tracked via
status.created and status.ready. If a VirtualMachineInstance exists in the cluster,
status.created will equal to true. If the VirtualMachineInstance is also ready,
status.ready will equal true too.

If a VirtualMachineInstance reaches a final state but the spec.running equals true,
the VirtualMachine controller will set status.ready to false and
re-create the VirtualMachineInstance.

Restarting

A VirtualMachineInstance restart can be triggered by deleting the VirtualMachineInstance. This
will also propagate configuration changes from the template in the
VirtualMachine:

When to use a VirtualMachine

When ABI stability is required between restarts

A VirtualMachine makes sure that VirtualMachineInstance ABI configurations
are consistent between restarts. A classical example are licenses which are
bound to the firmware UUID of a virtual machine. The VirtualMachine
makes sure that the UUID will always stay the same without the user having to
take care of it.

One of the main benefits is that a user can still make use of defaulting logic,
although a stable ABI is needed.

When config updates should be picked up on the next restart

If the VirtualMachineInstance configuration should be modifyable inside the cluster and
these changes should be picked up on the next VirtualMachineInstance restart. This
means that no hotplug is involved.

When you want to let the cluster manage your individual VirtualMachineInstance

Kubernetes as a declarative system can help you to manage the VirtualMachineInstance.

You tell it that you want this VirtualMachineInstance with your application running,
the VirtualMachine will try to make sure it stays running.

Note: The current believe is that if it is defined that the
VirtualMachineInstance should be running, it should be running. This is different to
many classical virtualization platforms, where VMs stay down if they were
switched off. Restart policies may be added if needed. Please provide your
use-case if you need this!