Skip to content
Snippets Groups Projects
Commit 3a3a2bcc authored by Jerry Sun's avatar Jerry Sun
Browse files

Wrap Kubernetes host address in square brackets


When constructing the host address string, the address is
not wrapped in square brackets. This does not work in IPv6
Kubernetes deployments. This commit adds square brackets
around the address. IPv4 was also tested to ensure it works
with wrapped address.

Signed-off-by: default avatarJerry Sun <jerry.sun@windriver.com>
parent 0014ca34
No related branches found
No related tags found
No related merge requests found
...@@ -415,6 +415,9 @@ func inClusterConfig() (cluster k8sapi.Cluster, user k8sapi.AuthInfo, namespace ...@@ -415,6 +415,9 @@ func inClusterConfig() (cluster k8sapi.Cluster, user k8sapi.AuthInfo, namespace
err = fmt.Errorf("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined") err = fmt.Errorf("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined")
return return
} }
// we need to wrap IPv6 addresses in square brackets
// IPv4 also works with square brackets
host = "[" + host + "]"
cluster = k8sapi.Cluster{ cluster = k8sapi.Cluster{
Server: "https://" + host + ":" + port, Server: "https://" + host + ":" + port,
CertificateAuthority: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt", CertificateAuthority: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment