GoogleContainerTools / GoogleContainerTools/skaffold
Port-forwards with localPorts should fail if port is occupied, and fail early
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
Some users wish to establish port-forwards for HTTPS services to port 443. They need the port-forward to fail if this port is unavailable, and ideally it should fail early rather than waiting until the deployment has completed.
### Current behavior
With user-defined port-forwards, the `localPort` is acquired on a best-effort used.
```
portForward:
- resourceType: deployment
resourceName: myDep
namespace: mynamespace
port: 8080
localPort: 9000 # *Optional*
```
| field | description |
| ---- | -------- |
| localPort: | local port to forward to. If the port is unavailable, Skaffold will choose a random open port to forward to. Optional. |
### Proposed behavior
Revise port-forwarding as follows:
- a `portForward` without a `localPort` should attempt to acquire the requested `port`, subject to our current restrictions (i.e., port ≥ 1024)
- if `localPort` is a non-zero value, then it should be acquired OR the Skaffold session should fail. (If unspecified, the `localPort` is set to 0.)
Further, Skaffold should check and fail on start if requested local-ports are not available.
Contributor guide
Assessment
This issue has not been assessed yet.