From 3a3a2bcc86097480d97958549a6e965febde8e92 Mon Sep 17 00:00:00 2001 From: Jerry Sun Date: Thu, 6 Feb 2020 12:58:18 -0500 Subject: [PATCH] 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: Jerry Sun --- storage/kubernetes/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/kubernetes/client.go b/storage/kubernetes/client.go index 795dcc22..025c4dde 100644 --- a/storage/kubernetes/client.go +++ b/storage/kubernetes/client.go @@ -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") return } + // we need to wrap IPv6 addresses in square brackets + // IPv4 also works with square brackets + host = "[" + host + "]" cluster = k8sapi.Cluster{ Server: "https://" + host + ":" + port, CertificateAuthority: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",