fix(cli): propagate global client-config flags to ssh/scp proxy command#2678
Open
LopatinDmitr wants to merge 1 commit into
Open
fix(cli): propagate global client-config flags to ssh/scp proxy command#2678LopatinDmitr wants to merge 1 commit into
LopatinDmitr wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
d8 v sshandd8 v scpdidn't respect the global connection flags (--context,--kubeconfig,--server, …). These commands tunnel data through aport-forwardthat 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@vmconnected 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>andd8 v scp --context <ctx> <src> <dst>reach the VM in<ctx>. With-v=3the logged ProxyCommand now carries the forwarded flags (e.g.--context=<ctx>).Checklist
Changelog entries