Skip to content

feat: add GPU CRD to lease cloud GPU runtimes via a provider interface - #164

Merged
edenreich merged 7 commits into
mainfrom
feat/issue-163-20260719-1749
Jul 22, 2026
Merged

edenreich merged 7 commits into
mainfrom
feat/issue-163-20260719-1749

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Summary

Introduces a namespaced GPU custom resource that provisions and manages externally hosted, GPU-backed inference runtimes. The Kubernetes cluster is the control plane only; GPU hardware, drivers, scheduling and inference execution stay with an external infrastructure provider (RunPod first) behind a pluggable provider interface.

What's included

  • API (api/v1alpha1/gpu_types.go): GPU kind with provider, credentialsRef, image, command, gpuTypes, endpoint{port,readinessPath}, required maxRuntime; status with phase, instanceID, url, connectionSecretRef, startedAt/expiresAt, and a Ready condition. Phases: Pending/Provisioning/Starting/Ready/Terminating/Expired/Failed.
  • Provider interface (internal/gpu/provider.go): Provision/Get/Destroy with an idempotent-by-UID contract and a name-based factory.
  • RunPod driver (internal/gpu/runpod.go): standard-library-only REST client. Recovers an existing pod by UID tag before creating, builds the proxy URL, treats Not Found as successful cleanup.
  • Controller (internal/controller/gpu_controller.go): full lifecycle state machine - persists instanceID for crash recovery, gates Ready=True on the actual HTTP readinessPath, publishes a per-allocation connection Secret (never the provider key), enforces maxRuntime into Expired (no auto-reprovision), and a finalizer that releases the allocation on deletion.
  • Wired into cmd/main.go; RBAC, CRD, sample, PROJECT and the bundled manifests/*.yaml regenerated; examples/gpu shows a Gateway consuming the connection Secret via secretKeyRef.

Tests

  • RunPod client unit tests (httptest, offline): create, idempotent recovery, 404 handling, URL/port parsing.
  • envtest reconciliation tests: readiness-gated Ready + connection Secret, maxRuntime into Expired with no reprovision, crash-after-create-before-status-persist recovering a single allocation, finalizer cleanup, and missing-credentials into Failed.

All acceptance criteria in the issue are covered. task lint is clean and task test is green.

Notes / follow-ups

  • Endpoint auth: the operator generates a per-allocation token and injects it into the runtime as the API_KEY env var. Runtimes that expect a different variable will need that documented per image.
  • Gateway auto-discovery (an optional gpuRef) is intentionally out of scope for this first cut, per the issue.

Downstream impact

  • New public-facing CRD - a docs page should be added (tracking issue opened in inference-gateway/docs).
  • manifests/install.yaml / manifests/crds.yaml now ship the GPU CRD; any Helm packaging that mirrors these should pick it up on the next release.

Closes #163

Comment thread internal/gpu/runpod.go Resolved
Comment thread internal/gpu/runpod.go Resolved
Comment thread internal/gpu/runpod.go Resolved
Comment thread internal/gpu/runpod_test.go Resolved
Comment thread internal/gpu/runpod_test.go Resolved
Comment thread internal/gpu/runpod.go Fixed
@edenreich

Copy link
Copy Markdown
Contributor

@claude Code scanning is failing, can you fix this? btw the example is very confusing can you improve it, let's demonstrate how to deploy ornith using runpod provider. use /ponytail:ponytail

… between integer types'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 13m 43s —— View job


Done

  • Investigate the CodeQL failure on internal/gpu/runpod.go:174
  • Fix code scanning
  • Rework the examples/gpu example to deploy Ornith-1.0 via RunPod
  • Verify build/tests, keep prettier + manifests clean, commit

Pushed a9c945d.

Code scanning fix

The alert is the int32(...) narrowing in httpPort. The prior autofix used strconv.ParseInt(p, 10, 32); I tightened it to the correct width for a TCP port:

if n, err := strconv.ParseUint(p, 10, 16); err == nil {
    return int32(n)
}

uint16 maxes at 65535, always within int32, so the conversion is provably in range (what CodeQL wants) and also rejects nonsense ports > 65535. Ports in the tests (8080, 9000) are unaffected.

Why the old example was confusing

It pointed llama.cpp at --model /models/qwen.gguf - a file the image never ships and nothing mounts, so it couldn't actually run. The reader had no idea where the model came from.

The reworked examples/gpu serves Ornith-1.0 (agentic-coding model) with vllm/vllm-openai, which pulls the weights from Hugging Face by id (deepreinforce-ai/Ornith-1.0-9B) at startup - nothing to bake in or mount:

  • Dense 9B checkpoint on a single 80GB GPU. Documented that the RunPod driver leases one GPU (gpuCount: 1), so the 35B/397B MoE checkpoints (multi-GPU sharding) are out of scope.
  • readinessPath: /health (vLLM's readiness endpoint), port: 8000, 80GB gpuTypes, --max-model-len 32768 so the KV cache fits.
  • Added an auth note: the operator injects the per-allocation token as API_KEY, but vLLM expects VLLM_API_KEY - so the demo serves openly behind the unguessable RunPod proxy URL. This was already flagged as a per-image follow-up in the PR; now it's explicit in the docs.
  • Updated config/samples/core_v1alpha1_gpu.yaml to match.

Verification

go build ./... and go test ./internal/gpu/... pass. Ran prettier --write on the touched files; the kustomize sample is prettier-clean (unchanged), so task manifests won't dirty the tree. No API/RBAC markers changed, so no manifest regeneration is needed.

Note: CI (including CodeQL) was mid-run when you commented; it'll re-run on the new commit.
· branch feat/issue-163-20260719-1749

@inference-gateway-maintainer inference-gateway-maintainer Bot moved this to Todo in 2026 Jul 20, 2026
@edenreich edenreich moved this from Todo to In progress in 2026 Jul 20, 2026
@edenreich edenreich moved this from In progress to QA in 2026 Jul 21, 2026
@edenreich
edenreich merged commit 3e582f1 into main Jul 22, 2026
1 check passed
@edenreich
edenreich deleted the feat/issue-163-20260719-1749 branch July 22, 2026 12:32
@edenreich edenreich moved this from QA to Done in 2026 Jul 22, 2026
inference-gateway-releaser Bot added a commit that referenced this pull request Jul 22, 2026
## [0.20.0](v0.19.1...v0.20.0) (2026-07-22)

### ✨ Features

* add GPU CRD to lease cloud GPU runtimes via a provider interface ([#164](#164)) ([3e582f1](3e582f1))

### 🐛 Bug Fixes

* **gateway:** Map telemetry.traces.exporter.otlp to TRACING_OTLP_ENDPOINT env vars ([#169](#169)) ([7ddf4a8](7ddf4a8))

### 👷 CI

* **deps:** bump sigs.k8s.io/gateway-api in the gomod group ([#165](#165)) ([9f55bd8](9f55bd8))
* **deps:** bump the github-actions group with 2 updates ([#166](#166)) ([26c8846](26c8846))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.20.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] GPU CRD: provision cloud GPU instances (RunPod first) via a pluggable provider interface

2 participants