From e8992598994d1522179b9db2e02b5bd27a0bbce6 Mon Sep 17 00:00:00 2001 From: Lukas Wuttke Date: Fri, 5 Jun 2026 13:30:53 +0200 Subject: [PATCH] fix(installer): point kubeconfig at the client namespace after deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After `helm upgrade --install` into the fixed `tracebloc` namespace, set the current kubeconfig context's namespace to it — so `kubectl` and the tracebloc CLI (`cluster info` / `dataset push`) default to the right namespace with no -n / --namespace flag. Without this the context stayed on `default`, so the first post-install CLI command errored: "no tracebloc parent client release found in namespace default". The documented next step (`tracebloc dataset push ./data`) hit it too. - Best-effort (`|| true`) so it never aborts an otherwise-successful install. - Honors TB_NAMESPACE overrides (uses the var, not a hardcoded name). - Mirrored in install-k8s.ps1. - New bats test asserts the set-context call with the namespace. Co-Authored-By: Claude Opus 4.8 --- scripts/install-k8s.ps1 | 4 ++++ scripts/lib/install-client-helm.sh | 5 +++++ scripts/tests/install-client-helm.bats | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/scripts/install-k8s.ps1 b/scripts/install-k8s.ps1 index 0830fc7..da7809c 100644 --- a/scripts/install-k8s.ps1 +++ b/scripts/install-k8s.ps1 @@ -1214,6 +1214,10 @@ $envBlock Log "Helm Output: $helmOutput" if ($LASTEXITCODE -ne 0) { Err "Client installation failed. Helm output:`n$helmOutput`nCheck the log for details: $LOG_FILE" } + # Point kubeconfig's current context at the client namespace so kubectl + the + # tracebloc CLI default to it (no -n / --namespace needed). Best-effort. + kubectl config set-context --current --namespace $TB_NAMESPACE 2>$null | Out-Null + Ok "Connected to tracebloc" Log "Values file: $valuesFile" } diff --git a/scripts/lib/install-client-helm.sh b/scripts/lib/install-client-helm.sh index 41e0615..c21ac6e 100644 --- a/scripts/lib/install-client-helm.sh +++ b/scripts/lib/install-client-helm.sh @@ -383,6 +383,11 @@ EOF cat "$helm_log" >> "${LOG_FILE:-/dev/null}" 2>/dev/null rm -f "$helm_log" + # Point the kubeconfig's current context at the client namespace, so kubectl and + # the tracebloc CLI default to it with no -n / --namespace flag. Best-effort: + # a failure here must not abort an otherwise-successful install. + kubectl config set-context --current --namespace "$TB_NAMESPACE" >/dev/null 2>&1 || true + success "Connected to tracebloc" log "Values file: $values_file" } diff --git a/scripts/tests/install-client-helm.bats b/scripts/tests/install-client-helm.bats index e9565bc..67c66ac 100644 --- a/scripts/tests/install-client-helm.bats +++ b/scripts/tests/install-client-helm.bats @@ -135,6 +135,19 @@ setup() { mock_calls | grep -q "helm upgrade --install tracebloc" } +@test "install_client_helm: points kubeconfig at the client namespace (so the CLI needs no -n)" { + HOST_DATA_DIR="$BATS_TEST_TMPDIR/data"; mkdir -p "$HOST_DATA_DIR" + _ensure_tracebloc_dirs() { :; } + _ensure_release_dirs() { :; } + _ensure_helm_runnable() { :; } + helm() { return 0; } + kubectl() { record "kubectl $*"; return 0; } + verify_credentials() { printf valid; } + run install_client_helm <<< $'myid\nmypw' + [ "$status" -eq 0 ] + mock_calls | grep -q "kubectl config set-context --current --namespace tracebloc" +} + @test "install_client_helm: re-prompts on invalid, then accepts valid" { HOST_DATA_DIR="$BATS_TEST_TMPDIR/data"; mkdir -p "$HOST_DATA_DIR" _ensure_tracebloc_dirs() { :; }