feat(controller): make Go (ADK) runtime agent image independently configurable#2021
feat(controller): make Go (ADK) runtime agent image independently configurable#2021QuentinBisson wants to merge 4 commits into
Conversation
3e0ab42 to
10a9c6f
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Go (ADK) runtime image configurability so operators can override registry/repository/pull policy independently from the default (Python) agent image, while preserving the existing derived-repo behavior.
Changes:
- Introduces
controller.goAgentImageHelm values and wires them into the controller ConfigMap asGO_IMAGE_*settings. - Adds controller flags for Go runtime image overrides and a
DefaultGoImageConfigto drive translation. - Updates translator logic + adds unit tests covering explicit Go repo/registry overrides and fallback derivation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| helm/kagent/values.yaml | Adds controller.goAgentImage values with fallback/derivation semantics. |
| helm/kagent/templates/controller-configmap.yaml | Exposes Go image override values via GO_IMAGE_* entries when set. |
| go/core/pkg/app/app.go | Adds --go-image-* flags to set Go-specific image defaults. |
| go/core/internal/controller/translator/agent/adk_api_translator.go | Introduces DefaultGoImageConfig global for Go runtime image overrides. |
| go/core/internal/controller/translator/agent/deployments.go | Applies Go-specific registry/pullPolicy overrides and optional repository override logic. |
| go/core/internal/controller/translator/agent/runtime_test.go | Adds tests for explicit Go repo/registry overrides and fallback derivation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| commandLine.StringVar(&agent_translator.DefaultGoImageConfig.Registry, "go-image-registry", "", "The registry to use for the Go (ADK) runtime agent image. When empty, falls back to --image-registry.") | ||
| commandLine.StringVar(&agent_translator.DefaultGoImageConfig.Repository, "go-image-repository", "", "The repository to use for the Go (ADK) runtime agent image. When empty, derived from --image-repository by replacing the last path segment with \"golang-adk\".") | ||
| commandLine.StringVar(&agent_translator.DefaultGoImageConfig.PullPolicy, "go-image-pull-policy", "", "The pull policy to use for the Go (ADK) runtime agent image. When empty, falls back to --image-pull-policy.") |
| img := deployment.Spec.Template.Spec.Containers[0].Image | ||
| assert.Contains(t, img, "/kagent-golang-adk@", "Image should use the explicit flat repository") | ||
| assert.NotContains(t, img, "/golang-adk@", "Derived path must not appear when repository is explicitly set") | ||
| assert.Contains(t, img, "@sha256:test-go-base") |
| // Resolve base registry and pull policy; Go runtime uses DefaultGoImageConfig fields | ||
| // when set, falling back to DefaultImageConfig for any unset field. | ||
| baseRegistry := DefaultImageConfig.Registry | ||
| basePullPolicy := DefaultImageConfig.PullPolicy | ||
| if runtime == v1alpha2.DeclarativeRuntime_Go { | ||
| if DefaultGoImageConfig.Registry != "" { | ||
| baseRegistry = DefaultGoImageConfig.Registry | ||
| } | ||
| if DefaultGoImageConfig.PullPolicy != "" { | ||
| basePullPolicy = DefaultGoImageConfig.PullPolicy | ||
| } | ||
| } |
…figurable
Adds DefaultGoImageConfig (registry, repository, pullPolicy) with per-field
fallback to DefaultImageConfig and the existing golang-adk derivation logic.
Exposed as --go-image-{registry,repository,pull-policy} flags (auto-mapped to
GO_IMAGE_* env vars via LoadFromEnv) and as controller.goAgentImage.* Helm values.
Fixes registry layouts where the Python repository is a flat name that cannot
produce a valid path via last-segment replacement (e.g. kagent-golang-adk).
Tag is not configurable — Go runtime images are digest-pinned at link time.
Closes kagent-dev#2018
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
ac8e81a to
b54ae33
Compare
| // the derived repository (last segment of DefaultImageConfig.Repository replaced with | ||
| // "golang-adk") when Repository is empty. Tag is unused — Go runtime images are | ||
| // digest-pinned at controller link time via GoADKImageDigest / GoADKFullImageDigest. | ||
| var DefaultGoImageConfig = ImageConfig{} |
There was a problem hiding this comment.
Why don't we just encode the defaults into this variable like we do for the other image configs?
There was a problem hiding this comment.
Hey @iplay88keys I wanted to preserve the issue's framing.
The empty default was there to avoid a breaking change: the controller currently derives the Go image from agentImage.repository, so anyone mirroring images only sets that one value and the Go image follows. If we hardcode the default and always emit GO_IMAGE_REPOSITORY, their next helm upgrade silently repoints the Go image back to cr.kagent.dev and pods fail to pull.
I do agree that this is not the better change though and I will replace this PR with the way it is done for the other images.
Fixes #2018.
What
Adds
DefaultGoImageConfig(registry, repository, pullPolicy) to the translator with per-field fallback toDefaultImageConfigand the existinggolang-adkderivation when unset. Exposed end-to-end as:--go-image-{registry,repository,pull-policy}controller flags (auto-mapped toGO_IMAGE_*env vars via the existingLoadFromEnvmechanism)controller.goAgentImage.{registry,repository,pullPolicy}Helm valuesGO_IMAGE_*keys in the controller ConfigMap (only emitted when set, so a default install emits nothing and the fallback stays in the controller)Why
When
spec.declarative.runtime: gois used, the controller derives the Go runtime repository from the Python repository by replacing the last path segment withgolang-adk. This breaks for flat-name registry layouts (e.g. a mirrored registry where the image ismy-registry.io/kagent-golang-adk— the derivation cannot produce a hyphen-prefixed name).What doesn't change
GO_IMAGE_*keys are emitted in the ConfigMap, flags default to empty,DefaultGoImageConfigis all-zero.getRuntimeImageRepositoryfalls back to the existing string-surgery logic. Behavior is byte-for-byte identical.GoADKImageDigest/GoADKFullImageDigest.-fulldigest selection for sandboxed agents is unaffected.Files changed
go/core/internal/controller/translator/agent/adk_api_translator.goDefaultGoImageConfigvargo/core/internal/controller/translator/agent/deployments.gogetRuntimeImageRepository+resolveInlineDeploymentgo/core/pkg/app/app.go--go-image-*flagshelm/kagent/values.yamlcontroller.goAgentImageblockhelm/kagent/templates/controller-configmap.yamlGO_IMAGE_*keysgo/core/internal/controller/translator/agent/runtime_test.gowithGoImageConfighelper