-
-
Notifications
You must be signed in to change notification settings - Fork 508
Fix: Change DefaultAPIHost from 0.0.0.0 to 127.0.0.1 #1631
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: main
Are you sure you want to change the base?
Conversation
When generating the kubeconfig, if the API host is 0.0.0.0 (the default), replace it with 127.0.0.1 since 0.0.0.0 means "bind to all interfaces" but is not a valid address for clients to connect to. This fixes issues with tools like Headlamp that cannot connect to the cluster when the server URL uses 0.0.0.0. Fixes #1503 Co-authored-by: iwilltry42 <25345277+iwilltry42@users.noreply.github.com>
iwilltry42
left a comment
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.
You should change the DefaultAPIHost constant instead and potentially add checks for both the value from the constant and 0.0.0.0 in some places
Per reviewer feedback, changed the DefaultAPIHost constant from 0.0.0.0 to 127.0.0.1 instead of adding a runtime check. Also added checks for both the constant value and "0.0.0.0" in places where users might explicitly provide 0.0.0.0 for backward compatibility. Changes: - pkg/types/defaults.go: Changed DefaultAPIHost to 127.0.0.1 - pkg/client/registry.go: Added check for both DefaultAPIHost and 0.0.0.0 - pkg/client/cluster.go: Added check for both DefaultAPIHost and 0.0.0.0 - pkg/client/kubeconfig.go: Removed runtime replacement logic - pkg/client/kubeconfig_test.go: Updated test to verify constant value Co-authored-by: iwilltry42 <25345277+iwilltry42@users.noreply.github.com>
Changed Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
What
Changes the
DefaultAPIHostconstant from0.0.0.0to127.0.0.1inpkg/types/defaults.go, and adds backward compatibility checks for explicit0.0.0.0values in places where special handling is needed.Why
0.0.0.0is a valid bind address for servers but not a valid connect address for clients. Tools like Headlamp fail to connect when kubeconfig containshttps://0.0.0.0:PORT.Fixes #1503
Implications
127.0.0.1instead of0.0.0.0when no explicit host is specified--api-port HOST:PORTwill still get their specified hostDefaultAPIHostand"0.0.0.0"inpkg/client/registry.goandpkg/client/cluster.goto handle cases where users explicitly provide0.0.0.0Original prompt
This section details on the original issue you should resolve
<issue_title>[BUG] context saved in kubectl config set as 0.0.0.0</issue_title>
<issue_description>## What did you do
How was the cluster created?
k3d registry create linkerd --default-network podman
k3d cluster create linkerd --registry-use k3d-linkerd -a 2 -s 1 -i rancher/k3s:v1.32.0-k3s1
What did you do afterwards?
kubectl works fine but tools like headlamp won't connect i solved this by changing https://0.0.0.0:11892 https://127.0.0.1:11892
What did you expect to happen
headlamp should connect to the cluster
Screenshots or terminal output
If applicable, add screenshots or terminal output (code block) to help explain your problem.
Which OS & Architecture
i'm running this on windows 11 with podman desktop 1.15 & wsl 2 installed
Which version of
k3dWhich version of docker