Skip to content

petrkotas/virt-vmconfig-crd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Persistent Virtual Machine Kubernetes add-on

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.

Get started

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.

Install

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.

Legacy

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.

Usage of PVMs

Once the new PVM CRD has been added, you can start using it. You can:

Create new PVM

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

Legacy

If you are using the original Kubevirt vagrant environment, you can use this command

cluster/kubectl.sh --core create -f example.yaml

List PVMs

To get the list of existing PVMs in your Kubernetes cluster use the command

kubectl get pvms

Legacy

For the original Kubevirt vagrant environment use

cluster/kubectl.sh --core get pvms

Delete PVM

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

Legacy

For the original Kubevirt vagrant environment use

cluster/kubectl.sh --core delete -f example.yaml

Use as a library

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

About

The virtual machine CRD definition for kubernetes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published