Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support of named ports for kubectl port-forward #69477

Merged
merged 1 commit into from
Oct 10, 2018
Merged

Adds support of named ports for kubectl port-forward #69477

merged 1 commit into from
Oct 10, 2018

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Oct 5, 2018

What this PR does / why we need it:

Adds support of named ports for kubectl port-forward, so users will be able to run commands like this:

kubectl port-forward http-server http
kubectl port-forward http-server :http
kubectl port-forward http-server 8000:http

Same will work with services (including translation of the service's port into the pod's port).

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes kubernetes/kubectl#538

Special notes for your reviewer:

Please, note that this PR also includes #69403 which needs to be reviewed and merged first (it makes an util function to be exportable, so we can use it in the port-forward command).

Release note:

It is now possible to use named ports in the `kubectl port-forward` command

/sig cli
/kind feature

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. sig/cli Categorizes an issue or PR as relevant to SIG CLI. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/kubectl needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 5, 2018
return parts[0], parts[1]
}

return parts[0], parts[0]
Copy link
Contributor

@juanvallejo juanvallejo Oct 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just return "" for the second value here

I see, missed the use-case for returning the same value here in the changes below

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 6, 2018
@m1kola
Copy link
Member Author

m1kola commented Oct 6, 2018

Rebased

@krmayankk
Copy link

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 8, 2018
@m1kola
Copy link
Member Author

m1kola commented Oct 8, 2018

/retest

if err != nil {
containerPort, err := util.LookupContainerPortNumberByName(pod, remotePort)
if err != nil {
return ports, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, just return nil, err here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

@juanvallejo
Copy link
Contributor

@m1kola thanks for the PR.
cc @soltysh for approval

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2018
@juanvallejo
Copy link
Contributor

@m1kola please squash into single commit

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2018
@m1kola
Copy link
Member Author

m1kola commented Oct 8, 2018

@juanvallejo please, re-approve. I rebased and squashed.

Sorry for this. I tried to split PR into multiple smaller PRs for easier review.

@juanvallejo
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2018
@m1kola
Copy link
Member Author

m1kola commented Oct 8, 2018

/retest

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: m1kola, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 10, 2018
@k8s-ci-robot k8s-ci-robot merged commit 128b8fe into kubernetes:master Oct 10, 2018
@m1kola m1kola deleted the port-forward_named_port branch October 11, 2018 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port-forward should support named ports
5 participants