GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Local `func run` Kafka via sub-process adapter · Issue #4124 · knative/func

Local func run Kafka via sub-process adapter #4124

New issue
Copy link
New issue
Copy link
Open
Open
Local func run Kafka via sub-process adapter#4124
Copy link
Labels
kind/enhancementFeature additions or improvements to existing

Description

@aliok
aliok
opened on Nov 4, 2026
Issue body actions

Summary

Bring the language-agnostic Kafka runtime to local func run by running the adapter as a sub-process next to the function, delivering records as CloudEvents over loopback HTTP — the same contract as the on-cluster sidecar. This makes local Kafka work for every language (not just Go) with no per-language code, and unblocks retiring the in-process Go path (func-go#194).

Full design: https://gist.github.com/aliok/ff624d15f7e91fd55bbc4b3083456d47

Problem

On the cluster, Kafka is handled by a standalone runtime image (func-adapter-kafka, pinned as DefaultKafkaRuntimeImage): a separate container consumes records and POSTs each as a CloudEvent to the function, committing the offset only on 2xx. The function serves plain CloudEvents over HTTP and contains no Kafka code.

Local func run has not followed. Today the runners inject FUNC_TRANSPORT=kafka + KAFKA_* onto the function, which drives the Go CloudEvents scaffolding's in-process kafka.Start. That path is Go-only, and there is no Pod locally to hold a sidecar — so no other language has a local Kafka path, and deleting the in-process code (func-go#194) would regress local Go Kafka func run to a no-op. This issue is the replacement that must land first.

Approach

The adapter is a self-contained, env-configured, pure-Go, CGO-free binary that already reads the exact KAFKA_* env the runners produce, waits for its FUNCTION_TARGET to come up, and commits only on 2xx. Local Kafka therefore reduces to: run the adapter binary as a child of func run, pointed at the function's port, with the Kafka env moved from the function to the adapter.

  • Delivery: go:embed the matching GOOS/GOARCH adapter binary into each per-platform func release at build time (built from the pinned adapter module — nothing downloaded at build or run time); extract + exec it at runtime. No container runtime, no runtime network, no toolchain required on the user's machine. The adapter cross-compiles cleanly to the entire func release matrix (~11 MB stripped); func embeds it only on plausible developer-machine arches (darwin/{arm64,amd64}, linux/{amd64,arm64}, windows/{amd64,arm64}) and emits a clear "unavailable on this platform" message on the skipped server/mainframe targets.
  • Topology: the adapter runs as a host process for both backends — targeting the exec-child function (host builder) or the function container's published host port (container builder). One uniform code path.
  • Config: relocate KAFKA_* from the function to the adapter, drop FUNC_TRANSPORT entirely, set FUNCTION_TARGET to the function's dynamic local port and LISTEN_ADDRESS to a free port.
  • Credentials: run Kafka cred values through the same Interpolate helper every Run.Envs value already uses, so Kafka inherits func's local-run semantics verbatim — {{ env:NAME }} resolves from the OS environment (how a SASL password is supplied locally), inline values pass through, and cluster {{ secret:… }} refs pass through unresolved as they do for every other env today. A one-line warning (not an error) fires when a Kafka credential is an unresolved cluster ref, since for a credential a literal passthrough guarantees a confusing auth failure. TLS fields are host file paths.
  • Lifecycle: the adapter hangs off the existing func run supervision seam (shared context, job.Errors, teardown), with log multiplexing and orphan handling.
  • Version: the embedded binary is pinned in lockstep with DefaultKafkaRuntimeImage so local and deployed runs use the identical adapter.

Tasks

  • Single source of truth for the adapter version (DefaultKafkaRuntimeVersion) shared by the image reference and the build-time binary.
  • Build-system steps that produce the pinned adapter binary per GOOS/GOARCH into an embed location, riding the existing release matrix.
  • go:embed package exposing Extract() with version+checksum caching into the func data dir (exec bit; .exe on Windows).
  • Wire the adapter into both runners (host + container): start after the function when Kafka is configured, with KAFKA_* + FUNCTION_TARGET + LISTEN_ADDRESS, bound to the run context / job.Errors / logs.
  • Relocate KAFKA_* to the adapter env and remove the FUNC_TRANSPORT=kafka function injection.
  • Readiness-gate the adapter by generalizing the existing host-runner readiness probe (waitFor/isReady) to an arbitrary host:port + endpoint, polling the adapter's /health/readiness under --start-timeout so a bad broker/credentials fails func run fast.
  • Graceful "local Kafka unavailable on this platform" message on any target where the adapter isn't embedded (instead of a silent no-op).
  • Interpolate Kafka cred values via the existing Interpolate helper ({{ env:NAME }} + inline resolve locally; cluster {{ secret:… }} refs pass through as other envs do), with a one-line warning when a credential is an unresolved cluster reference.
  • Tests: unit (Extract(), adapter env assembly); integration for go + python (host builder) and one container-builder runtime against a local broker, over PLAINTEXT and SASL_SSL + SCRAM-SHA-512, asserting delivery + lag drains to 0; cross-platform embed smoke.

Related

  • Unblocks func-go#194 (retire the in-process Go Kafka path).

/kind enhancement

Activity

  1. knative-prow
    added
    kind/enhancementFeature additions or improvements to existing
    on Nov 4, 2026
  2. aliok
    added a commit that references this issue on Nov 19, 2026

    feat: complete local Kafka delivery for func run

    9ea1b09
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

    kind/enhancementFeature additions or improvements to existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.