diff --git a/test/infrastructure/container/docker.go b/test/infrastructure/container/docker.go index 269643411742..740a16cc79bd 100644 --- a/test/infrastructure/container/docker.go +++ b/test/infrastructure/container/docker.go @@ -756,9 +756,15 @@ func configurePortMappings(portMappings []PortMapping, config *dockercontainer.C HostIP: pm.ListenAddress, HostPort: fmt.Sprintf("%d", pm.HostPort), } + if pm.HostPort == 0 { + mapping.HostIP = "" + mapping.HostPort = "" + } hostConfig.PortBindings[port] = append(hostConfig.PortBindings[port], mapping) exposedPorts[port] = struct{}{} - exposedPorts[nat.Port(fmt.Sprintf("%d/tcp", pm.HostPort))] = struct{}{} + if pm.HostPort > 0 { + exposedPorts[nat.Port(fmt.Sprintf("%d/tcp", pm.HostPort))] = struct{}{} + } } config.ExposedPorts = exposedPorts diff --git a/test/infrastructure/docker/internal/docker/kind_manager.go b/test/infrastructure/docker/internal/docker/kind_manager.go index 2eec6a137b2f..9dedf83d83b1 100644 --- a/test/infrastructure/docker/internal/docker/kind_manager.go +++ b/test/infrastructure/docker/internal/docker/kind_manager.go @@ -109,13 +109,13 @@ func (m *Manager) CreateWorkerNode(ctx context.Context, name, image, clusterName func (m *Manager) CreateExternalLoadBalancerNode(ctx context.Context, name, image, clusterName, listenAddress string, port int32, _ clusterv1.ClusterIPFamily) (*types.Node, error) { // gets a random host port for control-plane load balancer // gets a random host port for the API server - if port == 0 { - p, err := getPort() - if err != nil { - return nil, errors.Wrap(err, "failed to get port for API server") - } - port = p - } + // if port == 0 { + // p, err := getPort() + // if err != nil { + // return nil, errors.Wrap(err, "failed to get port for API server") + // } + // port = p + // } // load balancer port mapping portMappings := []v1alpha4.PortMapping{{