-
Notifications
You must be signed in to change notification settings - Fork 381
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
Use localhost in admin kubeconfig again, if possible #5426
Conversation
If the API server is binding to all addresses, it's better to use the loopback interface to communicate with the API server locally. This avoids e.g. weird HTTP proxy problems. See: a759281 ("replace BindAddress by Address and OnlyBindToAddress") See: 548dc41 ("Add spec.api.bindAddress configuration") Signed-off-by: Tom Wieczorek <[email protected]>
if a.OnlyBindToAddress { | ||
host = net.JoinHostPort(a.Address, strconv.Itoa(a.Port)) | ||
} else { | ||
host = fmt.Sprintf("localhost:%d", a.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.
Why not use net.JoinHostPort
in this case 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.
We could, but we don't need to. JoinHostPort is only necessary if the host may be an IPv6 address, which, in this case, it isn't. Would you prefer to use it anyways?
var host string | ||
if a.OnlyBindToAddress { | ||
host = net.JoinHostPort(a.Address, strconv.Itoa(a.Port)) | ||
} else { | ||
host = fmt.Sprintf("localhost:%d", a.Port) | ||
} | ||
|
||
return &url.URL{Scheme: "https", Host: host} |
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.
It doesn't matter, but....
var host string | |
if a.OnlyBindToAddress { | |
host = net.JoinHostPort(a.Address, strconv.Itoa(a.Port)) | |
} else { | |
host = fmt.Sprintf("localhost:%d", a.Port) | |
} | |
return &url.URL{Scheme: "https", Host: host} | |
host := "localhost" | |
if a.OnlyBindToAddress { | |
host = a.Address | |
} | |
return &url.URL{Scheme: "https", Host: net.JoinHostPort(host, strconv.Itoa(a.Port))} |
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-1.31
git worktree add -d .worktree/backport-5426-to-release-1.31 origin/release-1.31
cd .worktree/backport-5426-to-release-1.31
git switch --create backport-5426-to-release-1.31
git cherry-pick -x 93b9f4ccc221af159d0e978c13fe9f37dfffb49b |
Description
If the API server is binding to all addresses, it's better to use the loopback interface to communicate with the API server locally. This avoids e.g. weird HTTP proxy problems.
See:
Type of change
How Has This Been Tested?
Checklist: