Skip to content

🍇 Ship a built-in Karta catalog and a cluster-or-catalog resolver API #86

Closed
2 of 2 issues completed

Description

@ronlv10

Value

A built-in catalog gives every Karta consumer working support for common workload types on day zero — on a fresh cluster, with no install step, no cluster access, and no hand-mapping of CRD fields. The definitions are curated, versioned, and tested alongside the code that uses them, so behavior can't silently drift. Cluster CRDs remain the way to override a built-in or add a new type at runtime; the catalog just guarantees a trusted default is always there. Net: "Karta supports any workload" becomes true out of the box, not only after someone populates the cluster.


Background

A key value Karta delivers is enabling platforms and controllers to support any workload type without per-CRD adapters. Users want to add support for a new workload type as quickly and seamlessly as possible, without first analyzing the operator or mapping CRD fields by hand.

Karta already ships definitions for a dozen popular frameworks under docs/samples/ (PyTorchJob, RayCluster, RayJob, LeaderWorkerSet, JobSet, MPIJob, KServe, Knative Serving, NIM Service, Milvus, Dynamo). Today they are hand-written YAML. They are not usable by Go callers at runtime, and hand-written YAML has no compile-time checking: a wrong field path, GVK, or drift from the Karta API type is only caught at runtime, if at all.


Proposal

Ship Karta with a built-in, curated registry of well-tested Karta definitions, with typed Go as the single source of truth, and expose a Go API so callers can resolve a Karta for any workload without writing one themselves.

The design has three parts:

1. Built-in registry package (pkg/builtin/)

A new pkg/builtin/ package holds both the curated definitions and the resolver API. Each sample becomes a typed *v1alpha1.Karta value in Go, one file per workload (e.g. pkg/builtin/jobset.go, pkg/builtin/pytorch.go). This is the canonical, contributor-friendly home for all built-in definitions. Field paths and GVKs are checked at compile time, and the jq-expression notes currently in YAML comments move into Go comments.

The same package indexes those definitions by workload identity and makes them available to any Go caller at runtime, with no go:embed of YAML. Callers decide how they use it: look for a Karta on the cluster first and fall back to the built-in registry, use the registry alone, or combine the two.

The API shape below is a high-level suggestion to seed discussion. Exact function names, signatures, and package structure should be decided during implementation.

The package exposes roughly:

  • A lookup function: given a workload identity, return the matching built-in Karta.
  • A registration function: let callers add their own Kartas at runtime (for internal workload types that will not be contributed upstream).
  • A list function: enumerate all workload types covered by the registry.

Callers that want cluster-first semantics compose it themselves: fetch from the cluster, and if not found, call the registry lookup. The registry is the building block; the composition is up to the caller.

These are illustrative suggestions. Names and signatures are open for discussion.

// Look up a built-in Karta by workload GVK — no cluster access needed.
karta, err := builtin.Get(gvk)

// Add an internal workload type not contributed upstream.
builtin.Add(myKarta)

// Cluster-first with registry fallback — composed by the caller.
karta, err := clusterClient.GetKarta(ctx, name)
if errors.IsNotFound(err) {
    karta, err = builtin.Get(gvk)
}

2. Generated YAML samples (docs/samples/)

A generator marshals every definition in pkg/builtin/ to YAML under docs/samples/, preserving the existing filename convention:
{group-slug}-{kind-lowercase}-{version}.yaml
(e.g. ray-io-raycluster-v1.yaml, kubeflow-org-pytorchjob-v1.yaml).

The YAML is generated output, not a source artifact. It exists for human readability and kubectl apply examples. A make generate-samples target regenerates it, and CI fails on any diff so docs/samples/ can never drift from pkg/builtin/. This mirrors the existing make validate pattern (git diff --exit-code).

3. Generation and CI

  • make generate-samples regenerates docs/samples/ from pkg/builtin/.
  • Wire generate-samples into the validate target so the existing git diff --exit-code check covers sample drift. CI already runs make check → validate; add an explicit CI step only if clearer.

Governance and CI

Contributions to pkg/builtin/ follow the same PR process as the rest of Karta. Every merged entry must be covered by tests that verify its structural validity and that key calculations (pod spec extraction, scale, status) produce correct results. CI fails when pkg/builtin/ and the generated docs/samples/ are out of sync.

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    enhancement
    on Jun 8, 2026
  2. changed the title [-]feat: ship a built-in Karta registry and a cluster-or-registry resolver API[/-] [+]🍇 Ship a built-in Karta registry and a cluster-or-registry resolver API[/+] on Jun 10, 2026
  3. changed the title [-]🍇 Ship a built-in Karta registry and a cluster-or-registry resolver API[/-] [+]🍇 Ship a built-in Karta catalog and a cluster-or-catalog resolver API[/+] on Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Target date

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions