Merge pull request #1061 from marqc/default_to_ipfamily_agnostic_localhost_host_address
CodeQL / Analyze (go) (push) Failing after 5m31s
Scorecard supply-chain security / Scorecard analysis (push) Failing after 1m32s

feat!: Set default host address value to `localhost`.
This commit is contained in:
Kubernetes Prow Robot
2025-06-16 14:22:58 -07:00
committed by GitHub
2 changed files with 30 additions and 12 deletions
+4 -3
View File
@@ -18,6 +18,7 @@ package types
import (
"fmt"
"net"
"os"
"sort"
"strconv"
@@ -44,7 +45,7 @@ const (
kubeletPortKey = "KUBELET_PORT"
kubeProxyPortKey = "KUBEPROXY_PORT"
defaultHostAddress = "127.0.0.1"
defaultHostAddress = "localhost"
defaultKubeletPort = "10248"
defaultKubeproxyPort = "10256"
)
@@ -78,8 +79,8 @@ func setKubeEndpoints() {
kubeProxyPort = o
}
kubeletHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostAddress, kubeletPort)
kubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostAddress, kubeProxyPort)
kubeletHealthCheckEndpoint = fmt.Sprintf("http://%s/healthz", net.JoinHostPort(hostAddress, kubeletPort))
kubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s/healthz", net.JoinHostPort(hostAddress, kubeProxyPort))
}
+26 -9
View File
@@ -109,9 +109,10 @@ func TestKubeEndpointConfiguration(t *testing.T) {
{
name: "no overrides supplied",
envConfig: map[string]string{},
expectedKubeletEndpoint: "http://127.0.0.1:10248/healthz",
expectedKubeProxyEndpoint: "http://127.0.0.1:10256/healthz",
}, {
expectedKubeletEndpoint: "http://localhost:10248/healthz",
expectedKubeProxyEndpoint: "http://localhost:10256/healthz",
},
{
name: "HOST_ADDRESS override supplied",
envConfig: map[string]string{
"HOST_ADDRESS": "samplehost.testdomain.com",
@@ -119,21 +120,37 @@ func TestKubeEndpointConfiguration(t *testing.T) {
expectedKubeletEndpoint: "http://samplehost.testdomain.com:10248/healthz",
expectedKubeProxyEndpoint: "http://samplehost.testdomain.com:10256/healthz",
},
{
name: "HOST_ADDRESS override supplied with IPv4",
envConfig: map[string]string{
"HOST_ADDRESS": "10.0.5.4",
},
expectedKubeletEndpoint: "http://10.0.5.4:10248/healthz",
expectedKubeProxyEndpoint: "http://10.0.5.4:10256/healthz",
},
{
name: "HOST_ADDRESS override supplied with IPv6",
envConfig: map[string]string{
"HOST_ADDRESS": "80:f4:16::1",
},
expectedKubeletEndpoint: "http://[80:f4:16::1]:10248/healthz",
expectedKubeProxyEndpoint: "http://[80:f4:16::1]:10256/healthz",
},
{
name: "KUBELET_PORT override supplied",
envConfig: map[string]string{
"KUBELET_PORT": "12345",
},
expectedKubeletEndpoint: "http://127.0.0.1:12345/healthz",
expectedKubeProxyEndpoint: "http://127.0.0.1:10256/healthz",
expectedKubeletEndpoint: "http://localhost:12345/healthz",
expectedKubeProxyEndpoint: "http://localhost:10256/healthz",
},
{
name: "KUBEPROXY_PORT override supplied",
envConfig: map[string]string{
"KUBEPROXY_PORT": "12345",
},
expectedKubeletEndpoint: "http://127.0.0.1:10248/healthz",
expectedKubeProxyEndpoint: "http://127.0.0.1:12345/healthz",
expectedKubeletEndpoint: "http://localhost:10248/healthz",
expectedKubeProxyEndpoint: "http://localhost:12345/healthz",
},
{
name: "HOST_ADDRESS and KUBELET_PORT override supplied",
@@ -174,8 +191,8 @@ func TestKubeEndpointConfiguration(t *testing.T) {
kubeProxyHCEndpoint := KubeProxyHealthCheckEndpoint()
kubeletHCEndpoint := KubeletHealthCheckEndpoint()
assert.Equal(t, kubeProxyHCEndpoint, test.expectedKubeProxyEndpoint)
assert.Equal(t, kubeletHCEndpoint, test.expectedKubeletEndpoint)
assert.Equal(t, test.expectedKubeProxyEndpoint, kubeProxyHCEndpoint)
assert.Equal(t, test.expectedKubeletEndpoint, kubeletHCEndpoint)
})
}
}