ITADN
k3d-io/k3d/Issues

Fix: Change DefaultAPIHost from 0.0.0.0 to 127.0.0.1

#1631Pull RequestCopilot 创建于 2025-12-01
C
Copilotcommented
# What Changes the `DefaultAPIHost` constant from `0.0.0.0` to `127.0.0.1` in `pkg/types/defaults.go`, and adds backward compatibility checks for explicit `0.0.0.0` values in places where special handling is needed. ```go // In pkg/types/defaults.go const DefaultAPIHost = "127.0.0.1" ``` # Why `0.0.0.0` is a valid bind address for servers but not a valid connect address for clients. Tools like Headlamp fail to connect when kubeconfig contains `https://0.0.0.0:PORT`. Fixes #1503 # Implications - **CLI behavior**: Kubeconfig will now use `127.0.0.1` instead of `0.0.0.0` when no explicit host is specified - **Existing clusters**: No impact on running clusters; only affects newly generated kubeconfig - **Explicit overrides**: Users specifying `--api-port HOST:PORT` will still get their specified host - **Backward compatibility**: Added checks for both `DefaultAPIHost` and `"0.0.0.0"` in `pkg/client/registry.go` and `pkg/client/cluster.go` to handle cases where users explicitly provide `0.0.0.0` - **Non-breaking**: Change only affects the kubeconfig output, not the actual port binding behavior <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> ---- *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 ``` lient: Podman Engine Version: 5.3.1 API Version: 5.3.1 Go Version: go1.23.3 Git Commit: 4cbdfde5d862dcdbe450c0f1d76ad75360f67a3c Built: Fri Nov 22 02:45:23 2024 OS/Arch: windows/amd64 Server: Podman Engine Version: 5.3.1 API Version: 5.3.1 Go Version: go1.22.7 Built: Thu Nov 21 11:00:00 2024 OS/Arch: linux/amd64 ``` ## Which version of `k3d` ``` k3d version v5.7.5 k3s version v1.30.6-k3s1 (default) ``` ## Which version of docker ``` podman version arch: amd64 cgroupdriver: cgroupfs cgroupversion: "1" endpoint: /var/run/docker.sock filesystem: extfs infoname: adampc name: docker os: fedora ostype: linux version: 5.3.1 PS C:\Users\adam.ADAMCIRILLO> podman version Client: Podman Engine Version: 5.3.1 API Version: 5.3.1 Go Version: go1.23.3 Git Commit: 4cbdfde5d862dcdbe450c0f1d76ad75360f67a3c Built: Fri Nov 22 02:45:23 2024 OS/Arch: windows/amd64 Server: Podman Engine Version: 5.3.1 API Version: 5.3.1 Go Version: go1.22.7 Built: Thu Nov 21 11:00:00 2024 OS/Arch: linux/amd64 PS C:\Users\adam.ADAMCIRILLO> podman version Client: Podman Engine Version: 5.3.1 API Version: 5.3.1 Go Version: go1.23.3 Git Commit: 4cbdfde5d862dcdbe450c0f1d76ad75360f67a3c Built: Fri Nov 22 02:45:23 2024 OS/Arch: windows/amd64 Server: Podman Engine Version: 5.3.1 API Version: 5.3.1 Go Version: go1.22.7 Built: Thu Nov 21 11:00:00 2024 OS/Arch: linux/amd64 podman info host: arch: amd64 buildahVersion: 1.38.0 cgroupControllers: - cpuset - cpu - cpuacct - blkio - memory - devices - freezer - net_cls - perf_event - net_prio - hugetlb - pids - rdma - misc cgroupManager: cgroupfs cgroupVersion: v1 conmon: package: conmon-2.1.12-2.fc40.x86_64 path: /usr/bin/conmon version: 'conmon version 2.1.12, commit: ' cpuUtilization: idlePercent: 97.73 systemPercent: 0.92 userPercent: 1.35 cpus: 8 databaseBackend: sqlite distribution: distribution: fedora variant: container version: "40" eventLogger: journald freeLocks: 2025 hostname: adampc idMappings: gidmap: null uidmap: null kernel: 5.15.167.4-microsoft-standard-WSL2 linkmode: dynamic logDriver: journald memFree: 28950421504 memTotal: 33634131968 networkBackend: netavark networkBackendInfo: backend: netavark dns: package: aardvark-dns-1.13.1-1.fc40.x86_64 path: /usr/libexec/podman/aardvark-dns version: aardvark-dns 1.13.1 package: netavark-1.13.1-1.fc40.x86_64 path: /usr/libexec/podman/netavark version: netavark 1.13.1 ociRuntime: name: crun package: crun-1.19.1-1.fc40.x86_64 path: /usr/bin/crun version: |- crun version 1.19.1 commit: 3e32a70c93f5aa5fea69b50256cca7fd4aa23c80 rundir: /run/crun spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL os: linux pasta: executable: /usr/bin/pasta package: passt-0^20241211.g09478d5-1.fc40.x86_64 version: | pasta 0^20241211.g09478d5-1.fc40.x86_64 Copyright Red Hat GNU General Public License, version 2 or later <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. remoteSocket: exists: true path: unix:///run/podman/podman.sock rootlessNetworkCmd: pasta security: apparmorEnabled: false capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT rootless: false seccompEnabled: true seccompProfilePath: /usr/share/containers/seccomp.json selinuxEnabled: false serviceIsRemote: true slirp4netns: executable: "" package: "" version: "" swapFree... </details> - Fixes k3d-io/k3d#1543 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
合并状态:未合并 1 条评论