Change:
} 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> } } }

Discussion:
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