Skip to content

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

@mheguy

Description

@mheguy

What happened?

Under the right conditions, the CLI will spit an error and fail to connect to a vcluster:

fatal unexpected server in kubeconfig:
https://example.com

What did you expect to happen?

vcluster connect to replace the hostname correctly.

How can we reproduce it (as minimally and precisely as possible)?

To repro: do not have docker installed, have a vcluster hostname that does not specify the port. Run vcluster connect


In pkg/cli/connect_helm.go L343-195 there is logic that handles processing the hostname.

If docker is not available, the hostname provided in the secret is parsed.
An error is raised if the server name is not split into 3 portions.

That's because the server name is assumed to specify the port.

So https://example.com:443 is valid but https://example.com is not.

I believe this should be modified:
If len of splitted == 3: port = splitted[2]
If len of splitted == 2: port = 443

Anything else we need to know?

No response

Host cluster Kubernetes version

Client Version: v1.34.3
Kustomize Version: v5.7.1
Server Version: v1.34.2-eks-b3126f4

vcluster version

vcluster version 0.30.2 (validated that this is current as of 4abf19a)

VCluster Config

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions