Skip to content

fix: set kubectl context in local terminal to match active cluster#374

Merged
nadaverell merged 2 commits intomainfrom
fix/local-terminal-context
Mar 28, 2026
Merged

fix: set kubectl context in local terminal to match active cluster#374
nadaverell merged 2 commits intomainfrom
fix/local-terminal-context

Conversation

@nadaverell
Copy link
Copy Markdown
Contributor

Summary

When opening a local terminal in Radar, the kubectl context wasn't set to the cluster being viewed — it used whatever context was default in the user's kubeconfig. This made running kubectl commands confusing since you had to manually switch context each time.

The fix creates a temporary copy of the kubeconfig with current-context set to Radar's active cluster, and points the shell's KUBECONFIG env var at it. The temp file is cleaned up when the session ends. Falls back to the original behavior if temp file creation fails.

  • internal/k8s/client.go — new WriteKubeconfigForCurrentContext() helper
  • internal/server/localterm.go — uses temp kubeconfig + cleanup on session end

Fixes #373

@nadaverell nadaverell requested a review from hisco as a code owner March 28, 2026 20:06
…uster

When opening a local terminal, the shell now gets a temporary kubeconfig
with current-context set to the cluster Radar is viewing, so kubectl
commands target the right cluster without manual context switching.

Fixes #373
@nadaverell nadaverell force-pushed the fix/local-terminal-context branch from 930afb8 to 8a8daf5 Compare March 28, 2026 20:08
Lockfile was missing @tanstack/react-query@5.95.2, tailwindcss@4.2.2,
and @tanstack/query-core@5.95.2, causing CI frontend job to fail.
@nadaverell nadaverell merged commit 630cd9a into main Mar 28, 2026
5 of 6 checks passed
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.

Terminal kubectl context is not set to the cluster you're currently viewing

1 participant