Open tthvo opened 4 hours ago
This issue is currently awaiting triage.
SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted
label.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
What happened:
From the usage description of the
kubectl port-forward
command:I suppose the
REMOTE_PORT
is required, meaning non-empty? However, when I usedkubectl port-forward
with an empty remote port, for example,kubectl port-forward pods/my-chart-app-v4-79747999fd-fw7nz 8080:
(didn't mean to do that but happened to), the command picks up the first port without a name.What you expected to happen:
I expect the command to exit error and print a warning about it.
How to reproduce it (as minimally and precisely as possible):
Follow the tutorial here: https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/
You should see the output:
I expect this to fail instead.
Anything else we need to know?:
Sorry if this is the intended behaviour for
kubectl
. Then, this issue is invalid.Otherwise, I think this block of code just needs to check for empty
remotePort
and returns an error.https://github.com/kubernetes/kubectl/blob/f829c4b78958aade1b0585e4b1816db636e3098d/pkg/cmd/portforward/portforward.go#L228-L236
Environment:
kubectl version
):v2.37.1
(Openshiftv4.15.14
)cat /etc/os-release
): Fedora Linux Workstation 40