feat: add branch connect for k8s backend - #1
Merged
Merged
Conversation
The k8s backend only creates a ClusterIP Service for a branch's compute, unlike the docker backend which binds a host port directly via Spec.HostPGPort. There was no way to reach a k8s-backed branch from the host without a separate kubectl port-forward. Add `branch connect <name>`: a blocking foreground command that forwards a local port to the compute Pod using client-go's programmatic portforward API (no kubectl subprocess), following the same interruptible foreground-only pattern kubectl port-forward itself and kubefwd use. Daemonizing is left to the caller (nohup + pid tracking). PortForward lives on k8s.Backend directly rather than the Backend interface, since the docker backend has no equivalent need and finding the target Pod requires a *rest.Config the interface does not expose.
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.
Summary
kubectl port-forwardinvocation.branch connect <name>: a blocking foreground command that forwards a local port to the compute Pod using client-go's programmatic portforward API (nokubectlsubprocess). Daemonizing (if wanted) is left to the caller, following the same patternkubectl port-forwardandkubefwduse.PortForwardlives directly onk8s.Backend, not theBackendinterface — the docker backend has no equivalent need, and finding the target Pod requires a*rest.Configthe interface doesn't expose.Test plan
go vet ./...andgo test ./...pass, including new unit tests forfindPod's label-selector logic (fake clientset) andtrimScheme.branch create→branch connect --port 25555→psql -h localhost -p 25555 -U cloud_admin -d postgres -c 'select 1;'returned1.SIGTERMto theconnectprocess releases the port and exits 0 (confirmed vianc -zvconnection-refused after kill, and via the background job's own exit code).