kvm-device-plugin

kvm-device-plugin
is a Kubernetes Device Plugin that manages access to /dev/kvm
(Kernel-based Virtual Machine) devices. It allows workloads running in Kubernetes to request KVM access via the Device Plugin interface, ensuring proper communication with the kubelet.
Features
- Provides access to
/dev/kvm
for containers running in Kubernetes.
- Implements the Kubernetes Device Plugin API to manage KVM allocation.
- Ensures that only workloads explicitly requesting KVM access receive it.
Installation
To deploy the kvm-device-plugin
, apply the provided manifests:
LATEST="$(curl -s 'https://api.github.com/repos/anza-labs/kvm-device-plugin/releases/latest' | jq -r '.tag_name')"
kubectl apply -k "https://github.com/anza-labs/kvm-device-plugin/?ref=${LATEST}"
Usage
To request access to /dev/kvm
in a pod, specify the device resource in the resources
section:
apiVersion: v1
kind: Pod
metadata:
name: kvm-checker
spec:
restartPolicy: Never
containers:
- name: kvm-checker
image: busybox
command: ["sh", "-c", "[ -e /dev/kvm ]"]
resources:
requests:
devices.anza-labs.dev/kvm: '1' # Request KVM device
limits:
devices.anza-labs.dev/kvm: '1' # Limit KVM device
How It Works
- The
kvm-device-plugin
registers with the kubelet and advertises available KVM devices.
- When a pod requests the
devices.anza-labs.dev/kvm
resource, the device plugin assigns a /dev/kvm
device to the container.
- The container is granted access to
/dev/kvm
for virtualization tasks.
Compatibility
- Kubernetes 1.20+
- Nodes must have KVM enabled (check with
lsmod | grep kvm
)
License
kvm-device-plugin
is licensed under the Apache-2.0.
Attributions
This codebase is inspired by: