From 3cd005ae8faaabb41f98e3c6fdb59f5955644d79 Mon Sep 17 00:00:00 2001 From: NopeCharon <115794254+NopeCharon@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:19:41 +0000 Subject: [PATCH] docs: add guide for deploying to an existing cluster The only documented deployment paths are the KIND and AKS setup scripts, which label nodes and enable CDI in containerd as a side effect. Anyone deploying deploy/manifests/device-plugin.yaml to another cluster has to reverse-engineer those steps, and docs/architecture.md made this harder by claiming the device plugin labels nodes itself. It does not: both DaemonSets select nodes with hyperlight.dev/enabled=true, so without the label nothing is scheduled. Add docs/existing-cluster.md covering: - prerequisites: amd64 nodes (the published image is linux/amd64 only), Kubernetes 1.29+ for CDI device references from device plugins, and a CDI-enabled container runtime reading /var/run/cdi - labeling nodes, including persistent labels for managed node pools - enabling CDI on containerd 1.7 (containerd 2.0 enables it by default) - rendering the manifest placeholders with envsubst and pinning a verified image digest - verifying the rollout and node allocatable, troubleshooting the common failure modes, and uninstalling Correct the Node Labels section of docs/architecture.md to say the labels must be applied by the operator, and link the new guide from the README and the architecture next steps. Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com> --- README.md | 1 + docs/architecture.md | 9 ++- docs/existing-cluster.md | 142 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 docs/existing-cluster.md diff --git a/README.md b/README.md index 65ddda2..f1e08f6 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ kubectl logs -l app=hyperlight-hello -f | [Command Reference](docs/commands.md) | All `just` commands explained | | [Local Development](docs/local-development.md) | Test with KIND + local registry | | [Azure Deployment](docs/azure-deployment.md) | Production on AKS + ACR | +| [Existing Cluster Deployment](docs/existing-cluster.md) | Deploy to any other Kubernetes cluster | | [GHCR Publishing](docs/ghcr-publishing.md) | Publish images to GitHub | | [Architecture](docs/architecture.md) | How the device plugin works | diff --git a/docs/architecture.md b/docs/architecture.md index e87219f..1bd6c91 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -226,15 +226,18 @@ spec: ## Node Labels -The device plugin automatically labels nodes based on detected hypervisor: +The device plugin does not label nodes. Apply these labels to the nodes that should run Hyperlight workloads: | Label | Values | Purpose | |-------|--------|---------| -| `hyperlight.dev/enabled` | `true` | Device plugin runs on this node | -| `hyperlight.dev/hypervisor` | `kvm` or `mshv` | Which hypervisor is available | +| `hyperlight.dev/enabled` | `true` | Selects the nodes that run the device plugin DaemonSets | +| `hyperlight.dev/hypervisor` | `kvm` or `mshv` | Lets workloads select a hypervisor with `nodeSelector` | + +The KIND and AKS setup scripts apply these labels. On other clusters, apply them yourself; see [Existing Cluster Deployment](existing-cluster.md#1-label-the-hyperlight-nodes). ## Next Steps - [Local Development](local-development.md) - Test locally with KIND - [Azure Deployment](azure-deployment.md) - Deploy to AKS +- [Existing Cluster Deployment](existing-cluster.md) - Deploy to any other cluster - [GHCR Publishing](ghcr-publishing.md) - Publish images publicly diff --git a/docs/existing-cluster.md b/docs/existing-cluster.md new file mode 100644 index 0000000..f25c3e4 --- /dev/null +++ b/docs/existing-cluster.md @@ -0,0 +1,142 @@ +# Existing Cluster Deployment + +How to deploy the Hyperlight device plugin to a Kubernetes cluster you already run, without the KIND or AKS setup scripts. + +The `just local-up` and `just azure-up` scripts prepare nodes for you. On any other cluster, you need to do those steps yourself before applying the manifest. + +## Prerequisites + +| Requirement | Details | +|-------------|---------| +| **Nodes** | Linux `amd64` nodes exposing `/dev/kvm` or `/dev/mshv` on the host. The published image is built for `linux/amd64` only. | +| **Kubernetes** | Kubernetes 1.29+. The plugin returns CDI device references from `Allocate`, which requires the `DevicePluginCDIDevices` feature (beta and enabled by default from 1.29, GA in 1.31). | +| **Container runtime** | CDI enabled, with `/var/run/cdi` in its CDI spec directories. See [Enable CDI](#2-enable-cdi-in-the-container-runtime). | +| **Tools** | `kubectl` with cluster-admin access, and `envsubst` (`apt install gettext-base`). | + +Check that a node exposes a hypervisor device: + +```bash +# On the node +ls -la /dev/kvm /dev/mshv +``` + +## 1. Label the Hyperlight Nodes + +The device plugin does **not** label nodes. Both DaemonSets in `deploy/manifests/device-plugin.yaml` only run on nodes labeled `hyperlight.dev/enabled=true`, and workloads use `hyperlight.dev/hypervisor` in their `nodeSelector` to pick a hypervisor: + +```bash +# KVM nodes +kubectl label node hyperlight.dev/enabled=true hyperlight.dev/hypervisor=kvm + +# MSHV nodes +kubectl label node hyperlight.dev/enabled=true hyperlight.dev/hypervisor=mshv +``` + +If the device plugin finds both devices on a node, it uses `/dev/mshv`, so label such a node `hyperlight.dev/hypervisor=mshv`. + +Labels set with `kubectl label` are lost when a node is replaced. For autoscaled or managed node pools, set them in the node pool or kubelet configuration instead (for example `--node-labels`), as `deploy/azure/setup.sh` does for AKS. + +## 2. Enable CDI in the Container Runtime + +The device plugin writes its CDI spec to `/var/run/cdi/hyperlight.json` on each node. The container runtime must have CDI enabled and read specs from that directory, otherwise pods requesting `hyperlight.dev/hypervisor` either fail to start or start without the hypervisor device. + +**containerd 2.0+** enables CDI by default and reads both `/etc/cdi` and `/var/run/cdi`. No change is needed. + +**containerd 1.7** needs CDI enabled. Add these settings to the existing `[plugins."io.containerd.grpc.v1.cri"]` section of `/etc/containerd/config.toml` (create the section if it is missing): + +```toml +[plugins."io.containerd.grpc.v1.cri"] + enable_cdi = true + cdi_spec_dirs = ["/etc/cdi", "/var/run/cdi"] +``` + +Then restart containerd on the node: + +```bash +sudo systemctl restart containerd +``` + +For other runtimes, check their documentation for how to enable CDI and make sure `/var/run/cdi` is one of the spec directories. + +## 3. Deploy the Device Plugin + +`deploy/manifests/device-plugin.yaml` contains `${IMAGE}`, `${DEVICE_COUNT}`, `${DEVICE_UID}` and `${DEVICE_GID}` placeholders. Substitute them with `envsubst` and apply the result: + +```bash +export IMAGE="ghcr.io/hyperlight-dev/hyperlight-device-plugin:latest" +export DEVICE_COUNT="2000" # concurrent allocations per node +export DEVICE_UID="65534" # should match your pods' runAsUser +export DEVICE_GID="65534" # should match your pods' runAsGroup + +envsubst '${IMAGE} ${DEVICE_COUNT} ${DEVICE_UID} ${DEVICE_GID}' \ + < deploy/manifests/device-plugin.yaml | kubectl apply -f - +``` + +Listing the variables restricts `envsubst` to these placeholders, as the `just` deploy recipes do. See [Configuration](architecture.md#configuration) for what each setting controls. + +For production, replace the `latest` tag with a digest you have checked as described in [Verify Published Device Plugin Images](../README.md#verify-published-device-plugin-images), for example `ghcr.io/hyperlight-dev/hyperlight-device-plugin@sha256:`. + +The manifest also requests `hyperlight.dev/device-access`, a bootstrap resource that only the device plugin should use. Reserve it for the `hyperlight-system` namespace in your admission or quota policy. See [Bootstrap device access](architecture.md#bootstrap-device-access). + +## 4. Verify + +Wait for both DaemonSets to become ready: + +```bash +kubectl -n hyperlight-system rollout status daemonset/hyperlight-device-access +kubectl -n hyperlight-system rollout status daemonset/hyperlight-device-plugin +``` + +The labeled nodes should now advertise the `hyperlight.dev/hypervisor` resource: + +```bash +just status +``` + +Or, without `just`: + +```bash +kubectl get nodes -l hyperlight.dev/enabled=true -o custom-columns='NAME:.metadata.name,HYPERVISOR:.metadata.labels.hyperlight\.dev/hypervisor,ALLOCATABLE:.status.allocatable.hyperlight\.dev/hypervisor' +``` + +Then run a test pod as described in [Verify Device Injection](../README.md#verify-device-injection), using `test-pod-kvm.yaml` or `test-pod-mshv.yaml` to match the node's hypervisor. + +## Troubleshooting + +### Device plugin pods are not scheduled + +The DaemonSets show `DESIRED 0` when no node has the `hyperlight.dev/enabled=true` label: + +```bash +kubectl get nodes -l hyperlight.dev/enabled=true +``` + +### Node advertises no `hyperlight.dev/hypervisor` resource + +Check the device plugin logs and readiness: + +```bash +kubectl -n hyperlight-system get pods -o wide +kubectl -n hyperlight-system logs daemonset/hyperlight-device-plugin +``` + +The plugin reports its devices as unhealthy until the hypervisor check passes and `/var/run/cdi/hyperlight.json` is written. See [Readiness and repair](architecture.md#readiness-and-repair). + +### Test pod has no hypervisor device + +If the test pod starts but reports `/dev/kvm NOT FOUND` (or `/dev/mshv`), CDI is disabled in the container runtime, which then ignores the CDI device reference. If it fails to start with an error such as `unresolvable CDI devices hyperlight.dev/hypervisor=kvm`, the runtime does not read `/var/run/cdi`. In both cases, enable CDI as described in [step 2](#2-enable-cdi-in-the-container-runtime). + +## Uninstall + +```bash +kubectl delete -f deploy/manifests/device-plugin.yaml --ignore-not-found + +# Optionally remove the node labels +kubectl label node hyperlight.dev/enabled- hyperlight.dev/hypervisor- +``` + +## Next Steps + +- [Architecture](architecture.md) - How the device plugin works +- [Local Development](local-development.md) - Test locally with KIND +- [Azure Deployment](azure-deployment.md) - Deploy to AKS