mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Sample apiserver: Avoid etcd listening on DNS result for "localhost"
We've had a fun case of `Sample API Server using the current Aggregator` failing due to DNS returning a response for localhost that is not 127.0.0.1 and does not exist on the node, causing etcd trying to bind to a non-existing address and consequently failing. Trying to spare others this fun :)
This commit is contained in:
parent
9bd2912e7a
commit
096bdb7121
@ -21,6 +21,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -198,6 +199,12 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
podLabels := map[string]string{"app": "sample-apiserver", "apiserver": "true"}
|
podLabels := map[string]string{"app": "sample-apiserver", "apiserver": "true"}
|
||||||
replicas := int32(1)
|
replicas := int32(1)
|
||||||
zero := int64(0)
|
zero := int64(0)
|
||||||
|
etcdLocalhostAddress := "127.0.0.1"
|
||||||
|
if framework.TestContext.ClusterIsIPv6() {
|
||||||
|
etcdLocalhostAddress = "::1"
|
||||||
|
}
|
||||||
|
etcdURL := fmt.Sprintf("http://%s", net.JoinHostPort(etcdLocalhostAddress, "2379"))
|
||||||
|
|
||||||
mounts := []v1.VolumeMount{
|
mounts := []v1.VolumeMount{
|
||||||
{
|
{
|
||||||
Name: "apiserver-certs",
|
Name: "apiserver-certs",
|
||||||
@ -218,7 +225,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
Name: "sample-apiserver",
|
Name: "sample-apiserver",
|
||||||
VolumeMounts: mounts,
|
VolumeMounts: mounts,
|
||||||
Args: []string{
|
Args: []string{
|
||||||
"--etcd-servers=http://localhost:2379",
|
fmt.Sprintf("--etcd-servers=%s", etcdURL),
|
||||||
"--tls-cert-file=/apiserver.local.config/certificates/tls.crt",
|
"--tls-cert-file=/apiserver.local.config/certificates/tls.crt",
|
||||||
"--tls-private-key-file=/apiserver.local.config/certificates/tls.key",
|
"--tls-private-key-file=/apiserver.local.config/certificates/tls.key",
|
||||||
"--audit-log-path=-",
|
"--audit-log-path=-",
|
||||||
@ -232,6 +239,10 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
Image: etcdImage,
|
Image: etcdImage,
|
||||||
Command: []string{
|
Command: []string{
|
||||||
"/usr/local/bin/etcd",
|
"/usr/local/bin/etcd",
|
||||||
|
"--listen-client-urls",
|
||||||
|
etcdURL,
|
||||||
|
"--advertise-client-urls",
|
||||||
|
etcdURL,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user