Bake in Kubernetes port-forwarding - #2209
Open
rolandwalker wants to merge 1 commit into
Open
Conversation
rolandwalker
force-pushed
the
RW/add-kubernetes-tunnel
branch
from
September 7, 2026 14:46
09ee7cd to
b502162
Compare
rolandwalker
force-pushed
the
RW/add-kubernetes-tunnel
branch
4 times, most recently
from
September 8, 2026 11:27
e15a989 to
c24c2f9
Compare
The --kubectl-resource option names a Kubernetes resource, usually in
the form type/name, to which a tunnel is created using the kubectl
CLI tool. Mycli then connects over that tunnel.
The --port option will be needed if the remote service is on a
nonstandard port, for example
mycli --kubectl-resource=pod/mysql --user=root --port=13306
It is unfortunate that our three tunneling options have quite different
spellings
--ssh-jump
--boundary-id
--kubectl-resource
However, there is meaning behind them for each case. In this case, the
terminology in Kubernetes for the value of the argument is exactly a
"resource" (and Kubernetes has very precise terminology). And we
wouldn't call it a "jump" because the tunnel terminates at the resource.
DSNs also support `kubectl_resource` as a query parameter.
Future work: it is not entirely clear whether use of the keyring should
be suppressed for all kubectl connections. It is kept off here, because
of obvious issues with a naive implementation. For instance, the
Kubernetes context is ignored here. While the context _can_ be set via
--kubectl-options, it is not tracked by our logic, and there is no way
to make it part of the keyring identifier. Yet changing the context
_would_ change which resource we connect to, and presumably the
needed credentials would change.
Limitation: kubectl can port-forward to a _named_ port on the resource
we are connecting to, but the mycli --port option only accepts integers.
So, there is an argument for adding a second option --kubectl-port or
incorporating the (possibly non-integer) port into the resource string.
Or for extending --port to accept strings when --kubectl-resource is
given. Each would add complexity, and nothing stops us from choosing
one of those paths later if there is such a need. Since named ports
correspond to integers, the current functionality ought to be
sufficient.
rolandwalker
force-pushed
the
RW/add-kubernetes-tunnel
branch
from
September 8, 2026 11:35
c24c2f9 to
0768cba
Compare
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
The
--kubectl-resourceoption names a Kubernetes resource, usually in the formtype/name, to which a tunnel is created using thekubectlCLI tool. Mycli then connects over that tunnel.The
--portoption will be needed if the remote service is on a nonstandard port, for exampleIt is unfortunate that our three tunneling options have quite different spellings
However, there is meaning behind them for each case. In this case, the terminology in Kubernetes for the value of the argument is exactly a "resource" (and Kubernetes has very precise terminology). And we wouldn't call it a "jump" because the tunnel terminates at the resource.
DSNs also support
kubectl_resourceas a query parameter.Future work: it is not entirely clear whether use of the keyring should be suppressed for all
kubectlconnections. It is kept off here, because of obvious issues with a naive implementation. For instance, the Kubernetes context is ignored here. While the context can be set via--kubectl-options, it is not tracked by our logic, and there is no way to make it part of the keyring identifier. Yet changing the context would change which resource we connect to, and presumably the needed credentials would change.Limitation:
kubectlcan port-forward to a named port on the resource we are connecting to, but the mycli--portoption only accepts integers. So, there is an argument for adding a second option--kubectl-portor incorporating the (possibly non-integer) port into the resource string. Or for extending--portto accept strings when--kubectl-resourceis given. Each would add complexity, and nothing stops us from choosing one of those paths later if there is such a need. Since named ports correspond to integers, the current functionality ought to be sufficient.Checklist
changelog.mdfile.AUTHORSfile (or it's already there).