kubernetes / kubernetes/kubectl
Add Option to Automatically Open Browser to a Path when Port Forwarding
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
**What would you like to be added**:
I would like to add a optional `--browser` flag to the `port-forward` command to allow the CLI to automatically open the browser and point to a particular path with the correct hostname and port. So, `kubectl port-forward pod-0 :9090 --browser /admin` would open the port-forward and, if successful, then automatically open the user's default browser to `http://localhost:/admin`. The user could also specify protocol overrides (https vs http) if necessary.
We can use `github.com/pkg/browser` to deal with all the cross-platform browser issues as that package is well-used.
**Why is this needed**:
This will streamline the process of accessing that URL particularly when asking the operating system to pick a random open port so you no longer need to copy/paste from a terminal into a browser.
**Please note I've already implemented this in a local branch and would be happy to contribute it, but wanted to start with an issue first if there were any things about the design that warranted discussion.
Contributor guide
Research direction
Start with the port-forward command entry point and review how it reports the automatically chosen port and successful forwarding. The change is done when an optional browser path opens only after forwarding succeeds, using the selected hostname and port and allowing the requested protocol override.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100