diff --git a/controllers/openstackprovisionserver_controller.go b/controllers/openstackprovisionserver_controller.go index 29dc33d..48087c7 100644 --- a/controllers/openstackprovisionserver_controller.go +++ b/controllers/openstackprovisionserver_controller.go @@ -19,6 +19,7 @@ package controllers import ( "context" "fmt" + "net" "strconv" "time" @@ -32,6 +33,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" + k8snet "k8s.io/utils/net" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -606,5 +608,9 @@ func (r *OpenStackProvisionServerReconciler) getLocalImageURL( //We're using hostNetwork for the provisionserver pod host = provisionPods.Items[0].Status.HostIP } + + if k8snet.IsIPv6(net.ParseIP(host)) { + host = fmt.Sprintf("[%s]", host) + } return fmt.Sprintf("http://%s:%d/%s", host, instance.Spec.Port, baseFilename), nil } diff --git a/go.mod b/go.mod index e939acd..7554d36 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( k8s.io/api v0.28.7 k8s.io/apimachinery v0.28.7 k8s.io/client-go v0.28.7 + k8s.io/utils v0.0.0-20240310230437-4693a0247e57 sigs.k8s.io/controller-runtime v0.16.5 ) @@ -74,7 +75,6 @@ require ( k8s.io/component-base v0.28.7 // indirect k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect - k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect