Skip to content

fix(cli): handle kubeconfig servers without explicit ports#3919

Open
immanuwell wants to merge 1 commit into
loft-sh:mainfrom
immanuwell:fix/connect-kubeconfig-server-port
Open

fix(cli): handle kubeconfig servers without explicit ports#3919
immanuwell wants to merge 1 commit into
loft-sh:mainfrom
immanuwell:fix/connect-kubeconfig-server-port

Conversation

@immanuwell
Copy link
Copy Markdown

What issue type does this pull request address?
/kind bugfix

What does this pull request do? Which issues does it resolve?
resolves #3536

Fixes vcluster connect when the kubeconfig server has no explicit port, like https://example.com. Before this, the CLI split on : and bailed with unexpected server in kubeconfig. Bit of a footgun.

Repro:

  1. Docker unavailable, so connect uses port-forward.
  2. Kubeconfig server is https://example.com (no :443).
  3. Run vcluster connect.

Now it parses the server as a URL, keeps explicit ports, and uses implicit https/http ports when needed.

Please provide a short message that should be published in the vcluster release notes
Fixed vcluster connect for kubeconfig server URLs without explicit ports.

What else do we need to know?
Tests: go test ./pkg/cli -run 'TestPortForwardServer|TestExchangeContextName', go test ./pkg/cli ./pkg/util/portforward, go test ./pkg/...

E2E Tests

none

@immanuwell immanuwell requested a review from a team as a code owner May 7, 2026 17:11
Comment thread pkg/cli/connect_helm.go
case "http":
return "80", nil
default:
return "", fmt.Errorf("unexpected server in kubeconfig: %s", parsed.String())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same error message for both failure cases might be on purpose, right? Could be made more explicit by making the error text a const.

Suggested change
return "", fmt.Errorf("unexpected server in kubeconfig: %s", parsed.String())
return "", fmt.Errorf("unexpected server scheme in kubeconfig: %s", parsed.String())

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.

CLI: "unexpected server in kubeconfig" when docker unavailable and hostname is valid

2 participants