-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix url parse #11470
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
base: master
Are you sure you want to change the base?
fix url parse #11470
Conversation
|
@gojoy does this mean we need to re-insert the brackets for v6 addresses? |
3b79477 to
1e11897
Compare
Thank you for the reminder. I believe specifying the Host in the REST configuration is a good practice, as the client-go automatically handles IPv6 addresses through URL parsing. Refer to writeKubeconfig |
Signed-off-by: GitHub <noreply@github.com>
1e11897 to
ecf3589
Compare
|
Would you mind reviewing it once more? @caseydavenport |
| data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_PROTOCOL__", getEnv("KUBERNETES_SERVICE_PROTOCOL", "https")) | ||
| data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_HOST__", getEnv("KUBERNETES_SERVICE_HOST", "")) | ||
| data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_PORT__", getEnv("KUBERNETES_SERVICE_PORT", "")) | ||
| data = strings.ReplaceAll(data, "__KUBERNETES_HOST_PORT__", net.JoinHostPort(getEnv("KUBERNETES_SERVICE_HOST", ""), getEnv("KUBERNETES_SERVICE_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.
| data = strings.ReplaceAll(data, "__KUBERNETES_HOST_PORT__", net.JoinHostPort(getEnv("KUBERNETES_SERVICE_HOST", ""), getEnv("KUBERNETES_SERVICE_PORT", ""))) | |
| data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_HOST__", getEnv("KUBERNETES_SERVICE_HOST", "")) | |
| data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_PORT__", getEnv("KUBERNETES_SERVICE_PORT", "")) | |
| data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE__", net.JoinHostPort(getEnv("KUBERNETES_SERVICE_HOST", ""), getEnv("KUBERNETES_SERVICE_PORT", ""))) |
I think we need to leave the existing replace statements - some users provide their own CNI configuration templates and may be relying on this replacement. Just because they aren't used by the default config template doesn't mean they might not be used elsewhere.
Let's also call it KUBERNETES_SERVICE since HOST_PORT has a meaning already in k8s networking.
Description
after go 1.24.8.
url.Parseenforce stricter parsing of bracketed IPv6 hostnames, When the URL like https://[10.250.0.1]:443, the operation fails. Therefore, in the kubeconfig file generated by install-cni, the square brackets around KUBERNETES_SERVICE_HOST should be removed.Related issues/PRs
Todos
Release Note
Reminder for the reviewer
Make sure that this PR has the correct labels and milestone set.
Every PR needs one
docs-*label.docs-pr-required: This change requires a change to the documentation that has not been completed yet.docs-completed: This change has all necessary documentation completed.docs-not-required: This change has no user-facing impact and requires no docs.Every PR needs one
release-note-*label.release-note-required: This PR has user-facing changes. Most PRs should have this label.release-note-not-required: This PR has no user-facing changes.Other optional labels:
cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.