fleet

package
v1.801.437 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package fleet is your own compute, attached: bring a Kubernetes cluster, a GPU box or bare metal and run work on it.

It is the ONE per-org registry of that attached compute (BYO k8s clusters / BYO GPU / bare metal), the single source of truth consumed by BOTH the fleet surface (apps/visor, which serves /v1/clusters — managed clusters from Visor MERGED with these BYO ones) AND ML serving (apps/ml, whose dynForOrg federates a workload onto the org's registered cluster). One registry, two consumers — never a second cluster surface.

Tenant isolation is the org boundary, narrowed by the org SUB-SCOPE (project): the kubeconfig is sealed in the org's KMS (MPC nodes see only ciphertext) under a per-org(+project) ref prefix, and every method takes the org + project as resolved from the ZAP-propagated, gateway-validated X-Org-Id / X-Project-Id — never a client field. So lux sees only lux's clusters, zoo only zoo's, a customer only their own — and, within an org, one project's fleet is a distinct shard. The DEFAULT project (principal.IsDefaultProject) keeps the legacy org-only key, so existing single- project fleets are untouched (scopeRef).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeRESTConfig

func SafeRESTConfig(kubeconfig []byte) (*rest.Config, error)

SafeRESTConfig parses a kubeconfig into a REST config and is the ONE fold-safety gate every attach path funnels through (discovery-folded clusters AND hand-pasted BYO kubeconfigs). It REFUSES:

  • credential PLUGINS — restCfg.ExecProvider (an exec credential plugin runs a local binary with the pod's full environment inherited = RCE) and restCfg.AuthProvider (auth-provider plugins likewise shell out);
  • SSRF TARGETS — the apiserver host (restCfg.Host, the ACTUAL dial target the inventory List hits) must be https and publicly routable, never loopback / private / link-local / IMDS / unspecified / multicast.

This closes the exec-kubeconfig RCE and the "guard the endpoint we don't dial" SSRF for every caller at once — the kubeconfig's server is what gets dialed, so it is what gets guarded.

Types

type Cluster

type Cluster struct {
	Name       string `json:"name"`
	Org        string `json:"org"`
	Kind       string `json:"kind"`     // byo | byo-gpu | metal (managed clusters come from Visor, not here)
	Provider   string `json:"provider"` // byo | k3s | ...
	Endpoint   string `json:"endpoint,omitempty"`
	Nodes      int    `json:"nodes"`
	NvidiaGPU  int    `json:"nvidiaGpu"`
	AmdGPU     int    `json:"amdGpu"`
	Registered string `json:"registered"`
	Default    bool   `json:"default"`
}

Cluster is an attached compute source (metadata only — the kubeconfig is sealed separately in KMS and never surfaced). Owned by exactly one org.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is the KMS-backed BYO-cluster store. A nil KMS (unconfigured) makes it disabled: Register fails closed (never plaintext) and DynForOrg/List no-op.

func New

func New(brand string, log luxlog.Logger) *Registry

New opens the registry against the deployment's KMS (CLOUD_KMS_NODES / CLOUD_KMS_PASSPHRASE — the ONE bootstrap env, shared with the rest of cloud). Nil KMS => Enabled() is false and the registry is a graceful no-op.

func (*Registry) Deregister

func (r *Registry) Deregister(org, project, name string) (bool, error)

Deregister detaches a BYO cluster from the org+project fleet (index + sealed kubeconfig + cached client).

func (*Registry) DynForOrg

func (r *Registry) DynForOrg(org, project string) dynamic.Interface

DynForOrg returns the k8s client the org+project's workloads should target: its default registered cluster (KMS-loaded, cached) or nil when the shard has none (the caller then falls back to the home in-cluster client). This is the ONE federation seam.

func (*Registry) Enabled

func (r *Registry) Enabled() bool

Enabled reports whether BYO registration can persist (KMS reachable).

func (*Registry) List

func (r *Registry) List(org, project string) ([]Cluster, error)

List returns the org+project's registered BYO clusters (metadata only). Absent == empty.

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, org, project, name, kubeconfig, provider string, isDefault bool) (Cluster, error)

Register attaches a BYO cluster to the org+project fleet: validate by REACHING it (node + GPU inventory), seal the kubeconfig in the org's KMS, and index the metadata. Idempotent on name within the (org, project) shard.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL