Conversation
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
iplay88keys
force-pushed
the
iplay88keys/refactor-kagent-install
branch
from
October 28, 2026 20:59
7961bb9 to
a6c8cdf
Compare
iplay88keys
marked this pull request as ready for review
October 28, 2026 21:17
codyhartsook
left a comment
Contributor
There was a problem hiding this comment.
🤖 AI-generated review. I reviewed the findings before posting.
Two problems in the inputs the new library takes from embedders. I reproduced both with probe tests at a6c8cdf.
iplay88keys
commented
Oct 29, 2026
| KIND_SUBSTRATE_HELM_ARGS = --set atelet.extraArgs[0]=--localhost-registry-replacement=kind-registry:5000 --set ateApi.extraArgs[0]=--template-resync-interval=250ms | ||
| # A file only releases whose `kagent install` deploys the database contain. | ||
| CLI_DATABASE_SENTINEL = go/core/cli/internal/commands/bundled_postgres.yaml | ||
| CLI_DATABASE_SENTINEL = go/core/pkg/install/bundled_postgres.yaml |
Contributor
Author
There was a problem hiding this comment.
Correct, we aren't supporting upgrades from 0.10.x releases. The upgrade matrix here:
adjacent: skips because the PR targets main and the adjacent tests only run on release branches.prev-stable: selects v0.10.4, which lacks either of those paths, so changing it is fine here.
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
codyhartsook
self-requested a review
October 29, 2026 15:28
codyhartsook
approved these changes
Oct 29, 2026
adalundhe
pushed a commit
to adalundhe/kagent
that referenced
this pull request
Oct 29, 2026
## Description Add `kagent install --dry-run` to export a reviewable Helm installation recipe without changing the cluster. This builds on the reusable installation library in kagent-dev#3427 and exposes the exporter through `install.Export` for other callers. ```sh kagent --config config.yaml install --dry-run --output-dir ./kagent-install ``` The terminal reports the destination. The directory contains: ```text kagent-install/ ├── README.md ├── install.sh └── values/ ├── kagent-crds.yaml ├── substrate-crds.yaml ├── substrate-podcert.yaml ├── substrate.yaml └── kagent.yaml ``` `install.sh` contains ordered `helm upgrade --install` commands with the configured chart references, versions and namespaces. Each values file contains the merged installer overrides, including configured values files and generated settings. Chart defaults are not included. The README points to the Helm installation documentation and records the database mode and required credential variables. The CLI owns and embeds its README template. Library callers must provide template text through `ExportOptions.ReadmeTemplate`; rendering receives database mode and credential reference metadata. Optional `ExportOptions.ReadmeData` accepts caller-provided structs or maps, available to the template under `.Data`. The destination defaults to `./kagent-install` and must not already exist. Export requires Helm and chart access, but no kubectl, kubeconfig or model API-key value. It captures values-file contents so the result no longer depends on those input files. Local chart directories remain dependencies and become absolute references. CLI-managed API keys become environment references. The generated script binds them at execution time through `--set-file` and private temporary files. Other values are included as supplied; arbitrary secrets are not detected or sanitized. Library callers can declare additional credential references explicitly. The directory contains no database manifests, SQL or prerequisite setup scripts. Operators complete database and Substrate setup separately before applying it. `--skip-database-setup` retains the normal install's external-database configuration. The export does not calculate a diff against the cluster. ## Example output Examples from a local development export. Local chart paths are shown as `/path/to/kagent`. <details> <summary><code>README.md</code></summary> ````markdown # kagent Helm installation export This directory contains the Helm commands and values that `kagent install` would apply. Each values file contains only the values that the CLI sets for that release. Chart defaults are not included. Review every values file before you commit or share this directory. User-provided values are copied as supplied, and secrets in them are not detected or removed. Only the credentials in the Environment references section are replaced. ## Before you run the script Complete the prerequisite steps in the Helm installation guide: https://kagent.dev/docs/kagent/1.x/setup/installation/#before-you-begin. This export does not set up prerequisites. The values configure certificate authentication for the bundled database. This export does not provision the database. ## Environment references Set these environment variables before you run `install.sh`: - `OPENAI_API_KEY`: `providers.openAI.apiKey` in the `kagent` release The script passes each value to Helm with `--set-file` through a temporary private file. Always apply the export with the script. Helm does not expand environment variables in YAML, so passing a values file to Helm directly installs the placeholder text as the value. ## Run the script ```sh sh ./install.sh ``` The script installs the releases in order in the current kubeconfig context. Running it again upgrades the same releases. The export did not check the cluster or compute a diff. ```` </details> <details> <summary><code>install.sh</code></summary> ```sh #!/bin/sh set -eu # Complete the prerequisites in README.md before running these commands. script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) : "${OPENAI_API_KEY:?Set OPENAI_API_KEY before running this script}" umask 077 secret_dir=$(mktemp -d) trap 'rm -rf "$secret_dir"' EXIT trap 'exit 1' HUP INT TERM printf '%s' "${OPENAI_API_KEY}" > "$secret_dir/OPENAI_API_KEY" helm upgrade --install kagent-crds /path/to/kagent/helm/kagent-crds --version v1.0.0-alpha17-33-gba2448179 --namespace dry-run-validation --create-namespace --wait --wait-for-jobs --history-max 2 --timeout 5m -f "$script_dir/values/kagent-crds.yaml" helm upgrade --install substrate-crds oci://ghcr.io/kagent-dev/substrate/helm/substrate-crds --version 0.7.0-alpha1 --namespace ate-system --create-namespace --wait --wait-for-jobs --history-max 2 --timeout 5m -f "$script_dir/values/substrate-crds.yaml" helm upgrade --install substrate-podcert oci://ghcr.io/kagent-dev/substrate/helm/substrate-podcert --version 0.7.0-alpha1 --namespace podcertificate-controller-system --create-namespace --wait --wait-for-jobs --history-max 2 --timeout 5m -f "$script_dir/values/substrate-podcert.yaml" helm upgrade --install substrate oci://ghcr.io/kagent-dev/substrate/helm/substrate --version 0.7.0-alpha1 --namespace ate-system --create-namespace --wait --wait-for-jobs --history-max 2 --timeout 5m -f "$script_dir/values/substrate.yaml" helm upgrade --install kagent /path/to/kagent/helm/kagent --version v1.0.0-alpha17-33-gba2448179 --namespace dry-run-validation --create-namespace --wait --wait-for-jobs --history-max 2 --timeout 5m -f "$script_dir/values/kagent.yaml" --set-file providers.openAI.apiKey="$secret_dir/OPENAI_API_KEY" ``` </details> <details> <summary><code>values/kagent.yaml</code></summary> ```yaml config: substrate: apiEndpoint: dns:///api.ate-system.svc:443 routerUrl: http://atenet-router.ate-system.svc:80 controller: image: pullPolicy: Always substrateClientCertificate: enabled: true database: postgres: clientCertificate: enabled: true imagePullPolicy: Always providers: default: openAI openAI: apiKey: ${OPENAI_API_KEY} registry: localhost:5001 substrateWorkerPool: create: true workerImage: ghcr.io/kagent-dev/substrate/ateworker-gvisor:v0.7.0-alpha1 tag: v1.0.0-alpha17-33-gba2448179 ui: image: pullPolicy: Always ``` </details> ## Validation - CLI and library race tests, vet, and Go lint passed. - Helm tests compare exported overrides with normal install inputs, including precedence, set parsing, local chart paths and both database modes. - Script tests cover runtime credential binding, quoting, missing credentials and cleanup after success or failure. - Local export worked without cluster access; checks confirmed the expected files, valid shell syntax and no test API-key value. - The generated script worked on a fresh local install and a repeat install after prerequisite setup. - All five releases deployed with values matching the export. Signing pools were preserved, and CLI API access passed. --------- Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactor installation and uninstallation into a shared library to reduce duplication and make the workflow easier to extend. The existing implementation mixes setup and orchestration with CLI flags, environment reads, and terminal output, forcing other callers to duplicate that logic or depend on command internals.
Move the shared behavior into
core/pkg/installin the existing Go module. The CLI becomes a thin consumer that resolves configuration and credentials, reports progress, and checks API reachability. Embedding applications can reuse the same workflow and setup operations.Extension points are explicit inputs: chart artifacts, repositories, versions, values, worker images, and additional database setup SQL. An ordered plan keeps those choices separate from execution, while injected command and Kubernetes clients make the library testable without fake Helm and kubectl binaries on PATH.
The refactor preserves install ordering, signing-key reuse, controller service-account grants, and external-database cleanup protections. The upgrade-test manifest sentinel follows the moved asset. Plans retain values file paths and credential payloads.
Validation
go test -short -race ./core/pkg/install ./core/cli/...fromgo/go vet ./core/pkg/install ./core/cli/...fromgo/go build -o /tmp/kagent-install-library ./core/cli/cmd/kagentfromgo/make -C go lint— zero issuesinstall --helpsmoke checkmake kagent-cli-deploy AWK=/usr/bin/awk TOOLS_GO_VERSION=1.27.3against the local Kind clustergit diff --checkTests cover custom controller service accounts, alternate charts and additional schemas, skipped database setup, failed install/uninstall steps, cancellation, plan-copy isolation, PostgreSQL assets, and repeated prerequisite setup without key rotation.
Verified with a successful local install.