Skip to content

fix(cli): propagate global client-config flags to ssh/scp proxy command#2678

Open
LopatinDmitr wants to merge 1 commit into
mainfrom
fix/cli/ssh-proxy-client-flags
Open

fix(cli): propagate global client-config flags to ssh/scp proxy command#2678
LopatinDmitr wants to merge 1 commit into
mainfrom
fix/cli/ssh-proxy-client-flags

Conversation

@LopatinDmitr

Copy link
Copy Markdown
Contributor

Description

d8 v ssh and d8 v scp didn't respect the global connection flags (--context, --kubeconfig, --server, …). These commands tunnel data through a port-forward that is re-invoked as an SSH ProxyCommand, and that inner call was assembled without those flags, so it always fell back to the default context. It now inherits whatever the user passed to the outer command.

Why do we need it, and what problem does it solve?

On setups with more than one cluster, d8 v ssh --context other user@vm connected the tunnel to the default cluster instead — failing, or reaching a same-named VM in the wrong place. Every other command (console, vnc, lifecycle) already honored these flags; ssh/scp were the exception.

What is the expected result?

d8 v ssh --context <ctx> user@<vm> and d8 v scp --context <ctx> <src> <dst> reach the VM in <ctx>. With -v=3 the logged ProxyCommand now carries the forwarded flags (e.g. --context=<ctx>).

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: cli
type: fix
summary: "d8 v ssh and d8 v scp now connect to the cluster selected by global flags like --context and --kubeconfig."

The ssh and scp commands shell out to the local ssh/scp client with an
OpenSSH ProxyCommand that re-invokes `port-forward`. That reconstructed
command dropped all global connection flags, so the inner port-forward ran
against the default context/kubeconfig even when --context/--kubeconfig/
--server were passed to the outer command, tunneling to the wrong cluster.

Forward the flags the user set on the outer command to the inner
port-forward. The flag set is taken from kubeclient.ClientConfigFlagNames so
it cannot drift from what DefaultClientConfig binds; namespace is skipped as
it is already carried in the name.namespace target.

Signed-off-by: Dmitry Lopatin <dmitry.lopatin@flant.com>
@LopatinDmitr LopatinDmitr requested a review from Isteb4k as a code owner July 14, 2026 18:32
@LopatinDmitr LopatinDmitr added this to the v1.11.0 milestone Jul 14, 2026
@LopatinDmitr LopatinDmitr requested a review from diafour July 14, 2026 18:38
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.

1 participant