-
Notifications
You must be signed in to change notification settings - Fork 39.3k
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
Improve generated proxy URLs for cluster-info #53897
Conversation
@kubernetes/sig-cli-pr-reviews |
pkg/kubectl/cmd/clusterinfo.go
Outdated
scheme = "https" | ||
} | ||
|
||
name = utilnet.JoinSchemeNamePort(scheme, service.ObjectMeta.Name, port.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the last parameter be port.Port
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, if you specify a number, that just gets turned back into the port name server-side:
kubernetes/pkg/registry/core/service/rest.go
Lines 388 to 406 in 2986b37
// If a port *number* was specified, find the corresponding service port name | |
if portNum, err := strconv.ParseInt(portStr, 10, 64); err == nil { | |
svc, err := rs.registry.GetService(ctx, svcName, &metav1.GetOptions{}) | |
if err != nil { | |
return nil, nil, err | |
} | |
found := false | |
for _, svcPort := range svc.Spec.Ports { | |
if int64(svcPort.Port) == portNum { | |
// use the declared port's name | |
portStr = svcPort.Name | |
found = true | |
break | |
} | |
} | |
if !found { | |
return nil, nil, errors.NewServiceUnavailable(fmt.Sprintf("no service port %d found for service %q", portNum, svcName)) | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a comment? I thought this looked wrong too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. thanks @liggitt
Added comment |
/lgtm |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ericchiang, liggitt No associated issue. Update pull-request body to add a reference to an issue, or get approval with The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
1 similar comment
/retest Review the full test history for this PR. |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Fixes #53927
improves the output of
kubectl cluster-info
to print more qualified URLs, including changing the proxied scheme tohttps
if the service port name ishttps
or port number is 443