Fix: Change DefaultAPIHost from 0.0.0.0 to 127.0.0.1#1631
Draft
Fix: Change DefaultAPIHost from 0.0.0.0 to 127.0.0.1#1631
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>
Copilot
AI
changed the title
[WIP] Fix context saved in kubectl config as 0.0.0.0
Fix: Replace 0.0.0.0 with 127.0.0.1 in kubeconfig server URL
Dec 1, 2025
iwilltry42
requested changes
Dec 1, 2025
Member
iwilltry42
left a comment
There was a problem hiding this comment.
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>
Author
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:
|
Copilot
AI
changed the title
Fix: Replace 0.0.0.0 with 127.0.0.1 in kubeconfig server URL
Fix: Change DefaultAPIHost from 0.0.0.0 to 127.0.0.1
Dec 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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