An example Python implementation of a kubernetes client that interacts with the CoreWeave VirtualServer resource as well as the kubevirt subresource api.
- 1.Remove an existing Virtual Server.
- 2.Create of a new Virtual Server based on the
- 3.Wait for a Virtual Server
- 4.Stop the Virtual Server instance and wait until it is stopped.
- 5.Delete the Virtual Server instance.
In order to work around an unresolved issue with resource paths in the native Python client for kubevirt, we introduced the class
KubeVirtClientfor basic operations on kubevirt VirtualMachine resources.
Follow along by cloning the example script:
The vsclient provides an interface in the form of helper functions to interact with the Virtual Server resource, while the kubevirtclient provides an interface to interact with the kubevirt subresource API in order to stop and start a Virtual Server.
Both clients can be edited and used as drop-in clients for a simple Virtual Server controller built in Python.
virtualenv -p python3 .venv && source ./.venv/bin/activate
pip install kubernetes
Be sure to set secure credentials for your
PASSWORD, as they will be used to create a user in your Virtual Server.
USERNAME=<my_username> PASSWORD=<my_password> NAMESPACE=<my_namespace> KUBECONFIG=$HOME/.kube/config python3 main.py