Local Testing (No GPU Required)
Test the CastSlice webhook mutation logic on a local KinD or Minikube cluster with no physical NVIDIA GPU. You'll mock GPU capacity on the node and verify that the annotation-triggered rewrite works end-to-end.
This guide requires CastSlice to already be installed. If you haven't done that yet, follow the Getting Started guide first.
Step 1 — Mock a Node with nvidia.com/gpu capacity
Kubernetes does not allow kubectl patch to add arbitrary extended resources to status.capacity directly because the status sub-resource is guarded by the API server. The standard workaround is to PATCH the node directly via the raw API through kubectl proxy.
This modifies node status in your cluster. Only do this in a development or local cluster — never in production.
After this, the node advertises 4 fake nvidia.com/gpu resources. Kubernetes will schedule Pods requesting GPU resources against this node.
nvidia.com/gpu availableStep 2 — Apply the Test Pod
The repository includes a pre-built test Pod at docs/test-pod.yaml that requests a GPU and includes the castops.io/optimize: "true" annotation.
The Pod spec requests nvidia.com/gpu: 1 and has the opt-in annotation. CastSlice intercepts the CREATE admission request and rewrites it before it is persisted.
Step 3 — Verify the Mutation
Inspect the actual resource spec that was stored — this is what CastSlice wrote, not what you applied.
nvidia.com/gpu is gone — nvidia.com/gpu-shared: 1 took its placeMutation confirmed. The webhook intercepted the CREATE request, detected the opt-in annotation, and rewrote the resource limits via JSON Patch before the Pod was persisted to etcd.
Troubleshooting
Pod stays Pending after apply
If the fake node doesn’t also have the nvidia.com/gpu-shared resource, the Pod won’t be schedulable (it’s waiting for a resource that doesn’t exist on any node). For purely testing webhook mutation, you can check the stored spec immediately after kubectl apply — the Pod doesn’t need to reach Running state to verify the mutation happened.
Webhook is not mutating
Check that:
- The Pod (or Pod template) has
castops.io/optimize: "true"in itsmetadata.annotations - CastSlice is Running:
kubectl get pods -n cast-slice - The webhook is registered:
kubectl get mutatingwebhookconfigurations - cert-manager issued the certificate:
kubectl get certificate -n cast-slice
curl: (7) Failed to connect to localhost:8001
kubectl proxy may have already been killed or the port is different. Re-run kubectl proxy & and check the port it reports.