Change:
We have seen that on VirtualBox in particular kubelet picks first interfaces, which is usually NATed and is of no use. In particular the issue comes up with service IP, which gets mapped to endpoint on the NATed interface.
If this is still a problem, can you explain more - I don't quite understand - and suggest heuristics for better solutions?
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. Prevent issues from auto-closing with an comment. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale

Discussion:
Value: "tcp://machine:8080", }, { <del> Name:  "TEST_PORT_900_TCP", </del> <ins> Name:  "TEST_PORT_8080_TCP", </ins> Value: "tcp://machine:8080", }, { <del> Name:  "TEST_PORT_900_TCP_PROTO", </del> <ins> Name:  "TEST_PORT_8080_TCP_PROTO", </ins> Value: "tcp", }, { <del> Name:  "TEST_PORT_900_TCP_PORT", </del> <ins> Name:  "TEST_PORT_8080_TCP_PORT", </ins> Value: "8080", }, { <del> Name:  "TEST_PORT_900_TCP_ADDR", </del> <ins> Name:  "TEST_PORT_8080_TCP_ADDR", </ins> Value: "machine", }, {

func makeLinkVariables(service api.Service, machine string) []api.EnvVar { prefix := makeEnvVariableName(service.ID) <del> var port string if service.ContainerPort.Kind == util.IntstrString { port = service.ContainerPort.StrVal } else { port = strconv.Itoa(service.ContainerPort.IntVal) </del> <ins> protocol := "TCP" if service.Protocol != "" { protocol = service.Protocol </ins> } <del> portPrefix := prefix + "_PORT_" + makeEnvVariableName(port) + "_TCP" </del> <ins> portPrefix := fmt.Sprintf("%s_PORT_%d_%s", prefix, service.Port, strings.ToUpper(protocol)) </ins> return []api.EnvVar{ { Name:  prefix + "_PORT", <del> Value: fmt.Sprintf("tcp://%s:%d", machine, service.Port), </del> <ins> Value: fmt.Sprintf("%s://%s:%d", strings.ToLower(protocol), machine, service.Port), </ins> }, { Name:  portPrefix, <del> Value: fmt.Sprintf("tcp://%s:%d", machine, service.Port), </del> <ins> Value: fmt.Sprintf("%s://%s:%d", strings.ToLower(protocol), machine, service.Port), </ins> }, { Name:  portPrefix + "_PROTO", <del> Value: "tcp", </del> <ins> Value: strings.ToLower(protocol), </ins> }, { Name:  portPrefix + "_PORT",

import ( "fmt" <ins> "reflect" </ins> "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"

"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest" <del> "github.com/GoogleCloudPlatform/kubernetes/pkg/util" </del> ) func TestServiceRegistryCreate(t *testing.T) {

} func TestServiceRegistryMakeLinkVariables(t *testing.T) { <del> service := api.Service{ JSONBase:      api.JSONBase{ID: "foo-bar"}, Selector:      map[string]string{"bar": "baz"}, ContainerPort: util.IntOrString{Kind: util.IntstrString, StrVal: "a-b-c"}, } </del> registry := registrytest.NewServiceRegistry() registry.List = api.ServiceList{ <del> Items: []api.Service{service}, </del> <ins> Items: []api.Service{ { JSONBase: api.JSONBase{ID: "foo-bar"}, Selector: map[string]string{"bar": "baz"}, Port:     8080, Protocol: "TCP", }, { JSONBase: api.JSONBase{ID: "abc-123"}, Selector: map[string]string{"bar": "baz"}, Port:     8081, Protocol: "UDP", }, { JSONBase: api.JSONBase{ID: "q-u-u-x"}, Selector: map[string]string{"bar": "baz"}, Port:     8082, Protocol: "", }, }, </ins> } machine := "machine" vars, err := GetServiceEnvironmentVariables(registry, machine) if err != nil { t.Errorf("Unexpected err: %v", err) } <del> for _, v := range vars { if !util.IsCIdentifier(v.Name) { t.Errorf("Environment variable name is not valid: %v", v.Name) </del> <ins> expected := []api.EnvVar{ {Name: "FOO_BAR_SERVICE_HOST", Value: "machine"}, {Name: "FOO_BAR_SERVICE_PORT", Value: "8080"}, {Name: "FOO_BAR_PORT", Value: "tcp://machine:8080"}, {Name: "FOO_BAR_PORT_8080_TCP", Value: "tcp://machine:8080"}, {Name: "FOO_BAR_PORT_8080_TCP_PROTO", Value: "tcp"}, {Name: "FOO_BAR_PORT_8080_TCP_PORT", Value: "8080"}, {Name: "FOO_BAR_PORT_8080_TCP_ADDR", Value: "machine"}, {Name: "ABC_123_SERVICE_HOST", Value: "machine"}, {Name: "ABC_123_SERVICE_PORT", Value: "8081"}, {Name: "ABC_123_PORT", Value: "udp://machine:8081"}, {Name: "ABC_123_PORT_8081_UDP", Value: "udp://machine:8081"}, {Name: "ABC_123_PORT_8081_UDP_PROTO", Value: "udp"}, {Name: "ABC_123_PORT_8081_UDP_PORT", Value: "8081"}, {Name: "ABC_123_PORT_8081_UDP_ADDR", Value: "machine"}, {Name: "Q_U_U_X_SERVICE_HOST", Value: "machine"}, {Name: "Q_U_U_X_SERVICE_PORT", Value: "8082"}, {Name: "Q_U_U_X_PORT", Value: "tcp://machine:8082"}, {Name: "Q_U_U_X_PORT_8082_TCP", Value: "tcp://machine:8082"}, {Name: "Q_U_U_X_PORT_8082_TCP_PROTO", Value: "tcp"}, {Name: "Q_U_U_X_PORT_8082_TCP_PORT", Value: "8082"}, {Name: "Q_U_U_X_PORT_8082_TCP_ADDR", Value: "machine"}, {Name: "SERVICE_HOST", Value: "machine"}, } if len(vars) != len(expected) { t.Errorf("Expected %d env vars, got: %+v", len(expected), vars) return } for i := range expected { if !reflect.DeepEqual(vars[i], expected[i]) { t.Errorf("expected %#v, got %#v", vars[i], expected[i]) </ins> } } }