k9s icon indicating copy to clipboard operation
k9s copied to clipboard

Allow k9s to start without a valid Kubernetes context

Open uozalp opened this issue 3 weeks ago • 0 comments

Currently, k9s requires a valid kubectl context to be set before starting. If no context is configured or the configured context is unavailable, k9s fails to start with connection errors.

This PR changes that behavior:

  • k9s now starts successfully even without a valid context
  • Automatically shows the context view when no connection is available
  • Users can select their desired context from within k9s
  • Eliminates the need to run kubectl config use-context before launching k9s

Use case: Switch between different clusters (homelab/work) without pre-configuring kubectl context. Simply start k9s and select the appropriate context from the UI.

Backward compatibility: If a context is set via kubectl config use-context xxx, k9s behavior is unchanged. It will still load the last used view or the view defined in k9s.defaultView. This change only affects users who have no current context configured.

Changes:

  • Skip connection requirement during initialization
  • Prevent cluster updater and plugin loader from running without valid connection
  • Initialize factory/cluster model when switching from no-connection to valid context

Issue: https://github.com/derailed/k9s/issues/3705

uozalp avatar Dec 03 '25 18:12 uozalp