Skip to content

feat(build): register knative Node/TanStack builder#34

Open
nicacioliveira wants to merge 4 commits into
mainfrom
feat/knative-tanstack-serving
Open

feat(build): register knative Node/TanStack builder#34
nicacioliveira wants to merge 4 commits into
mainfrom
feat/knative-tanstack-serving

Conversation

@nicacioliveira

@nicacioliveira nicacioliveira commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

Register a knative builder in the operator's BuilderRegistry. For spec.serving.type=knative it creates a build Job that runs the generic Node build (DECO_TARGET=node) and uploads a self-contained dist tar to S3 (ArtifactKey), served by the generic node-runner (infra_applications PR #217).

Part of the plan (context PR #538). Additive — the cloudflare-worker path is unchanged.

Files

  • internal/build/knative.go — sibling of cfworkers.go; builds the Node build Job (env: DECO_TARGET=node, ARTIFACT_KEY, S3 buckets/region; Pod Identity, no static keys).
  • cmd/main.go — 2-line registration: registry.Register("knative", build.NewKnativeFactory(...)).

Compiles (go build ./internal/build/... ./cmd/...).

Remaining (next PRs)

  • Operator creates the Knative Service on build success for serving.type=knative (port of admin common/knative/service.ts → Go + knative serving client-go + RBAC services: create). Not in this PR.
  • The node builder image script (clone → npm ci → vite build --config vite.config.node.ts → tar → S3).

Draft — review only, nothing merged/deployed.


Summary by cubic

Adds a knative Node/TanStack builder and makes the operator create/update a generic node-runner Knative Service per commit to serve the S3-packed dist tar. The runner now uses IRSA via a dedicated ServiceAccount annotated with RUNNER_ROLE_ARN (no static S3 keys).

  • New Features

    • Added internal/build/knative.go to run Node builds (DECO_TARGET=node) and upload to S3 with ARTIFACT_KEY=ArtifactKey(org, site, commitSha); CR can override builder image/envs/secrets/TTL/nodeSelector/tolerations; uses Pod Identity.
    • Operator now ensures a serving.knative.dev Service (generic node-runner) on successful builds and for already-built sites. One revision per commit; env includes SOURCE_ASSET_PATH, DECO_SITE_NAME, DECO_ENV_NAME, ASSETS_BUCKET, AWS_REGION, and CR envs. Ensures the runner ServiceAccount exists and is IRSA-annotated (RUNNER_ROLE_ARN); runner image selected by framework via RunnerImages. Deco owns the Service.
    • Config from env: NODE_RUNNER_IMAGE, S3_ARTIFACTS_BUCKET, S3_REGION, RUNNER_SERVICE_ACCOUNT, RUNNER_ROLE_ARN, NODE_RUNNER_MIN_SCALE, NODE_RUNNER_MAX_SCALE, NODE_RUNNER_PORT, DECO_ENV_NAME. RBAC allows Knative Services create/update/patch and Revisions read. Wired via registry.Register("cloudflare-worker", "", ...), registry.Register("knative", "tanstack", ...), and KnativeServingConfigFromEnv().
  • Refactors

    • Builder registry now keys on (spec.serving.type, spec.framework) with a framework-agnostic fallback; tests updated and errors include the framework.

Written for commit b354fba. Summary will update on new commits.

Review in cubic

nicacioliveira and others added 2 commits July 21, 2026 21:05
Sibling of the cfworkers builder: creates a build Job that runs the generic
Node build (DECO_TARGET=node) and uploads a self-contained dist tar to S3
(ArtifactKey), served by the generic node-runner Knative Service. Registered in
the BuilderRegistry for spec.serving.type=knative. Additive — cloudflare-worker
path unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pe=knative

On a successful build (and idempotently on already-built reconciles), the
operator now creates/updates a generic node-runner Knative Service — the net-new
capability (previously admin created Knative Services). Renders serving.knative.dev
Service: node-runner image, port 8000, revision per commit, env from the CR
(SOURCE_ASSET_PATH=ArtifactKey, DECO_SITE_NAME, DECO_ENV_NAME, S3 config, +
spec.build.envs). Deco owns the Service (cascade delete). Adds RBAC
services:create;update;patch (config + chart). No-op for non-knative serving.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicacioliveira
nicacioliveira marked this pull request as ready for review July 22, 2026 18:14
nicacioliveira and others added 2 commits July 22, 2026 15:29
…type alone

Per review: serving.type=knative is the HOSTING framework; it doesn't say the
STACK (deno vs tanstack), and the same hosting runs different stacks. Key the
BuilderRegistry on the (servingType, framework) pair with a framework-agnostic
fallback (cloudflare-worker stays agnostic). knative builds register under
('knative','tanstack'); a future ('knative','deno') is a separate builder. The
Knative Service picks its runner image by framework (RunnerImages map). Keeps
the two dimensions orthogonal instead of collapsing into a 'tanstack-knative' string.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Knative Service runs the runner under a dedicated ServiceAccount
(RUNNER_SERVICE_ACCOUNT) annotated with RUNNER_ROLE_ARN (IRSA); the operator
ensures that SA exists+annotated in the site namespace. Injects AWS_REGION for
aws-cli; no ADMIN_S3_* keys. Read-only S3 identity, least-privilege.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment on lines +49 to +50
MinScale: atoiOr(os.Getenv("NODE_RUNNER_MIN_SCALE"), 0),
MaxScale: atoiOr(os.Getenv("NODE_RUNNER_MAX_SCALE"), 5),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets keep our current definitions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants