Skip to content

feat: add Lambda Cloud GPU provider - #153

Draft
googs1025 wants to merge 17 commits into
InftyAI:mainfrom
googs1025:feat/lambda-cloud-provider
Draft

googs1025 wants to merge 17 commits into
InftyAI:mainfrom
googs1025:feat/lambda-cloud-provider

Conversation

@googs1025

Copy link
Copy Markdown
Member

What this PR does / why we need it

Adds an opt-in lambda provider for Lambda Cloud On-Demand GPU instances. Nebula launches one VM per workload, starts a public container with cloud-init, and reports readiness after the container responds to /healthz. The initial catalog includes one A10 SKU.

Records launch attempts on NodeClaims so a lost API response can be recovered without starting a second instance. The adapter confirms termination before the NodeClaim finalizer releases.

Which issue(s) this PR fixes

Fixes #152

Special notes for your reviewer

  • make test, race tests for the Lambda adapter and virtual kubelet, and lint passed.
  • On a K3s cluster, a real Lambda A10 instance in us-west-1 ran the sample container and returned its GPU model from /healthz. The manager adopted the same VM after a restart. Deleting the smoke-test Pod removed its NodeClaim, and the Lambda API confirmed termination.
  • A separate one-replica Deployment reached 1/1 Ready on a real A10 instance.
  • kubectl logs and kubectl exec are deferred for the Lambda provider.

Does this PR introduce a user-facing change?

Nebula can run single-container On-Demand GPU workloads on Lambda Cloud using the opt-in `lambda` provider. Configure the Lambda credentials and workspace settings in `docs/deploy.md` to enable it.

@InftyAI-Agent InftyAI-Agent added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Nov 20, 2026
@googs1025
googs1025 marked this pull request as ready for review November 20, 2026 16:07
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Lambda workload restrictions prevent failover to compatible providers, and filtering terminated VM records can leave Pods Pending indefinitely after a lost launch response.

2 open issues
What changed in this PR

Adds an opt-in Lambda Cloud provider so Nebula can schedule single-container GPU workloads on On-Demand VMs, initially supporting one A10 SKU.

Changes:

  • Implements VM provisioning, cloud-init container startup, /healthz readiness checks, and confirmed termination.
  • Records launch attempts on NodeClaims and handles unresolved launches without immediately failing the Pod.
  • Adds provider registration, deployment configuration, samples, documentation, and tests.
File Description
pkg/​vnode/​handler.go Tracks unresolved launches and adopts recovered instances.
pkg/​vnode/​handler_test.go Tests unresolved launch recovery and teardown.
pkg/​provider/​lambda/​lambda.go Implements the Lambda provider lifecycle and readiness checks.
pkg/​provider/​lambda/​lambda_test.go Tests recovery, ownership, readiness, and concurrent provisioning.
pkg/​provider/​lambda/​client.go Adds the authenticated, rate-limited Lambda API client.
pkg/​provider/​lambda/​client_test.go Tests API responses, pagination failures, and error handling.
pkg/​provider/​lambda/​bootstrap.go Validates workloads and generates container startup scripts.
pkg/​provider/​lambda/​attempt.go Persists launch attempts and verifies instance ownership.
pkg/​provider/​errors.go Defines the unresolved-provision error.
pkg/​provider/​catalog/​data/​lambda.csv Adds the initial A10 offering.
hack/​deploy.sh Adds Lambda credential Secret creation.
docs/​deploy.md Documents configuration, supported workloads, and recovery.
config/​samples/​lambda-nodepool.yaml Provides an On-Demand Lambda NodePool example.
config/​samples/​lambda-deployment.yaml Provides a GPU workload with a health endpoint.
config/​rbac/​role.yaml Permits Lambda virtual-node impersonation.
config/​manager/​manager.yaml Loads optional Lambda credentials and configuration.
config/​catalog/​kustomization.yaml Includes the Lambda catalog in deployment configuration.
cmd/​main.go Registers Lambda with a direct API reader.
cmd/​main_test.go Tests explicit Lambda provider selection.
.env.example Adds the Lambda API key placeholder.

Review effort: Balanced

Comment thread pkg/provider/lambda/lambda.go Resolved
Comment thread pkg/provider/lambda/lambda.go Resolved
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@googs1025

Copy link
Copy Markdown
Member Author

@codex review this pr

@googs1025

Copy link
Copy Markdown
Member Author

/kind feature

@InftyAI-Agent InftyAI-Agent added feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Nov 21, 2026
@kerthcet
kerthcet requested a balanced review from Copilot November 21, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cold Pod adoption repeatedly probes the entire VM fleet, causing N² health requests after a manager restart and allowing slow probes to delay unrelated Pod adoption.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Avoid fleet-wide health probes on each cold pod adoption

pkg/​provider/​lambda/​lambda.go:508

Each cold GetPod calls instanceByClaim in pkg/vnode/handler.go, which invokes List for the entire provider. This loop then probes every active VM, so adopting N Pods after a manager restart performs N² /healthz requests rather than N; slow probes also delay adoption of unrelated Pods. Please use a claim-scoped, non-probing lookup for cold adoption and reserve fleet-wide health checks for the poll loop, or share a safely coalesced observation snapshot across these calls.

2 resolved since last review

Review effort: Balanced

@kerthcet

Copy link
Copy Markdown
Member

@googs1025 you should be able to ask copilot to review now, if not, let me know.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active polling races can apply stale observations to newer Pod entries or drop previously observed VMs, causing Pods to fail incorrectly or remain Pending indefinitely.

2 open issues

Review effort: Balanced

Comment thread pkg/vnode/handler.go Resolved
Comment thread pkg/provider/lambda/lambda.go Resolved
Copilot AI balanced review requested due to automatic review settings November 22, 2026 08:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because omitted findings identify risks of paid VM bootstrap failures and silently weakened workload isolation.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 22, 2026 15:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed for a timing-dependent claim/VM read race that can leave a launch attempt unresolved indefinitely, keeping the Pod Pending and blocking finalization.

No open issues 🎉

Review effort: Balanced

@googs1025

Copy link
Copy Markdown
Member Author

@kerthcet Could you review this PR when you have a chance? The previous review comments have been addressed, and I verified provisioning and cleanup on a real Lambda Cloud A10.

@kerthcet

Copy link
Copy Markdown
Member

/assign

Sure, will review this ASAP.

@kerthcet kerthcet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was quite busy in the past few days, but they've done. I took a quick glance at the code and leave some comments there, I think in general I'm a bit more relaxed about the implementation of lambda since we can change it later. But for the shared part, like the handlers, I think we should be more careful here. For example, if we can reuse the current code it would be really good since some of them are running in production now. But it doesn't mean we CAN NOT introduce new ones.

Let me know your thoughts here @googs1025 .

Comment thread docs/deploy.md Outdated
```bash
kubectl -n nebula-system create configmap nebula-lambda-config \
--from-literal='LAMBDA_WORKSPACE_ID=<workspace-id>' \
--from-literal=LAMBDA_REGION=us-west-1 \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, why we need to set the region here, shouldn't we just pick the region by the configuration in the nodePool.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NodePool now picks from the configured regions. The manager config pairs each region with its firewall ruleset.

# Approximate USD per instance-hour.
# https://lambda.ai/instances
accelerator_type,accelerator_id,gpu_count,capacity_type,price_per_hour,available,region,updated
A10,gpu_1x_a10,1,OnDemand,1.29,true,,2026-11-20

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a placeholder now and will add more later?

Comment thread docs/deploy.md Outdated

---

## Lambda Cloud

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any cloud specific section here, can we remove it. If you want, you can have a doc for lambda only.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the Lambda setup to docs/lambda.md and left a link in the deploy guide.

self.end_headers()
self.wfile.write(gpus)

HTTPServer(("0.0.0.0", 8080), Handler).serve_forever()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, is this a public endpoint if we run this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The example exposes port 8080 on the VM’s public IP. The firewall ruleset controls who can reach it. I added that to the guide.

return errors.As(err, &timeout) && timeout.Timeout()
}

func instanceName(nc *nebula.NodeClaim) string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is using this?

{"LAMBDA_REGION", &config.region},
{"LAMBDA_SSH_KEY_NAME", &config.sshKey},
{"LAMBDA_FIREWALL_RULESET_ID", &config.firewall},
{"LAMBDA_CLUSTER_ID", &config.cluster},

@kerthcet kerthcet Nov 25, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the cluster ID used for, seems Lambda uses the workspace id for isolation? Can you give me an example how it looks like?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

team-ml-prod is one example. Nebula uses the ID to tell which VMs belong to each deployment when several deployments share a Lambda workspace.

Comment thread pkg/provider/lambda/lambda.go Outdated
return provider.Capabilities{NativeTags: true, ProvisionTimeout: 60 * time.Second}
}

func geography(region string) string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a real region list here, it would be accurate. One case is europe-west-1 is London, but it's not eu in our system, it's uk.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guide points to Lambda’s /regions API for the region codes. The config maps each code to a Nebula geography, so a UK region can be listed under uk.

Comment thread pkg/vnode/handler.go Outdated
// An unreachable provider still counts as a failed attempt even though nothing gets
// blocklisted for it.
metrics.ObserveProvision(labels, time.Since(callStart), err)
if errors.Is(err, provider.ErrProvisionUnresolved) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be under err != nil

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the check inside if err != nil.

Comment thread pkg/vnode/handler.go Outdated
if errors.Is(err, provider.ErrProvisionUnresolved) {
log.Info("waiting to recover unresolved provision", "reason", err.Error())
h.markStatus(pod, corev1.PodPending, reasonProvisioning, "waiting for the provider to confirm the instance")
place.awaitingInstance = true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to introduce new state here if possible, can we treat this as unreserved and reusing what we have now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Pod stays in Provisioning, and I removed awaitingInstance. Reserved=false already expects an instance ID, so a lost launch response still uses ErrProvisionUnresolved while we look for the VM.

Comment thread pkg/provider/provider.go Outdated
InstanceFailed InstanceState = "Failed"
// InstanceUnknown: a claim could not be observed this tick. Keep its existing status
// and wait for a confirmed observation before adopting, failing or reprovisioning it.
InstanceUnknown InstanceState = "Unknown"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we have to introduce Unknown state or not, but the init state is Provisioning, why not just keep it in Provisioning?

Also one question about Lambda, is the Provision API a blocking request or a non-blocking one. For example, for Modal, it's a blocking one, so when the request responds with 201, it means we reserved one instance successfully, if not, we will mark the instance failed and then try another region.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed InstanceUnknown. A failed lookup leaves the Pod in its current state. Lambda returns the instance ID in the launch response, and Nebula checks readiness separately.

Preserve upstream region-table wiring and the Lambda API reader. Keep both the upstream environment test and the unresolved-launch recovery test.
Copilot AI balanced review requested due to automatic review settings November 30, 2026 06:08
@googs1025
googs1025 marked this pull request as draft November 30, 2026 06:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Secret-backed environment values bypass validation after virtual-kubelet resolution and are embedded in Lambda cloud-init user-data, exposing credentials.

1 open issue

Review effort: Balanced

Comment thread pkg/provider/lambda/bootstrap.go Outdated
Comment on lines +77 to +79
if len(req.Env.Secrets) != 0 || req.RegistryAuth != nil {
return fmt.Errorf("lambda: cloud-init requires a public image and non-secret environment: %w",
provider.ErrSpec)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambda now checks the original Pod for Secret refs before building cloud-init. The tests cover both secretKeyRef and envFrom using a Pod copy with the values already resolved.

@googs1025

googs1025 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member Author

I’ll do another pass on the whole PR and rerun the tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A VM observation race can leave durable launch attempts unresolved indefinitely, blocking recovery and finalization, while stale cold-lookup entries can suppress Pod provisioning.

3 open issues

Review effort: Balanced

Comment on lines +673 to +675
if record == nil {
return nil
}
Comment thread pkg/vnode/handler.go
}
continue
}
tp.resolveInstanceLookup(inst, present)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Categorizes issue or PR as related to a new feature. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Lambda Cloud as a GPU provider

4 participants