This add-on provides the functionality to store VM configuration in the Kubernetes cluster. It is designed to provide common grounds for building high-level Virtual Machine management tools on top of the Kubevirt.
That means, this add-on is designed to work in tandem with the Kubevirt.
The functionality present in this add-on is implemented as a Kubernetes Custom resource definition (CRD). Because of this approach, API heavy lifting is done by Kubernetes and does not have to be re-implemented.
Moreover, this add-on is also designed to provide golang language binding for building custom resource client. These bindings are autogenerated, therefore developers are not supposed to modify them.
Before you can do anything with this add-on, you have to get a local copy. To use the codes further as a library, use the golang tool.
go get github.com/petrkotas/virt-vmconfig-crd.git
With this method, you get functioning codes stored in your local GOPATH
.
If this is not desired, just clone the repository wherever you desire.
Installation is simple. Just run
kubectl create -f manifests/persistentvm-resource.yaml
give it few seconds and you are ready to go.
To verify everything went OK get existing CRD from the Kubernetes cluster.
kubectl get crd
If persistentvirtualmachines.kubevirt.io
is present, you are
good to go.
Besides the direct kubernetes installation. In case you are using the original Kubevirt vagrant deployment present in its GitHub repository. Use the following command.
make vagrant-deploy
This deploys the Kubevirt to the virtual machine running the Kubernetes with the Kubevirt.
Once the new PVM CRD has been added, you can start using it. You can:
Before you can register any new PVM in Kubernetes cluster, you have to define it first. New VM definition is done the same way as any other Kubernetes object, with the YAML file.
apiVersion: kubevirt.io/v1alpha1
kind: PersistentVirtualMachine
metadata:
name: testvm
spec:
domain:
devices:
consoles:
- type: neuralink
memory:
unit: MB
value: 64
os:
type:
os: AwesomeBrainOS
type: qemu
Once you have the specification ready, registering to Kubernetes cluster is as simple as
kubectl create -f my-pvm-example.yaml
If you are using the original Kubevirt vagrant environment, you can use this command
cluster/kubectl.sh --core create -f example.yaml
To get the list of existing PVMs in your Kubernetes cluster use the command
kubectl get pvms
For the original Kubevirt vagrant environment use
cluster/kubectl.sh --core get pvms
To delete existing PVM from you Kubernetes cluster use the command
kubectl delete pvm <your-PVM-name>
or if you have a YAML specification of the PVM, use
kubectl delete -f your-PVM-name.yaml
For the original Kubevirt vagrant environment use
cluster/kubectl.sh --core delete -f example.yaml
To use the generated bindings in your own code, just import the package in the go file and start using it.
import pvmcrd github.com/petrkotas/virt-vmconfig-crd/...
//TODO: Add proper example