Rename 'portal IP' to 'cluster IP' most everywhere

This covers obvious transforms, but not --portal_net, $PORTAL_NET and
similar.
This commit is contained in:
Tim Hockin
2015-05-23 13:41:11 -07:00
parent 46686616d4
commit 4318ca5a8b
43 changed files with 389 additions and 326 deletions

View File

@@ -32,16 +32,16 @@ func FromServices(services *api.ServiceList) []api.EnvVar {
for i := range services.Items {
service := &services.Items[i]
// ignore services where PortalIP is "None" or empty
// ignore services where ClusterIP is "None" or empty
// the services passed to this method should be pre-filtered
// only services that have the portal IP set should be included here
// only services that have the cluster IP set should be included here
if !api.IsServiceIPSet(service) {
continue
}
// Host
name := makeEnvVariableName(service.Name) + "_SERVICE_HOST"
result = append(result, api.EnvVar{Name: name, Value: service.Spec.PortalIP})
result = append(result, api.EnvVar{Name: name, Value: service.Spec.ClusterIP})
// First port - give it the backwards-compatible name
name = makeEnvVariableName(service.Name) + "_SERVICE_PORT"
result = append(result, api.EnvVar{Name: name, Value: strconv.Itoa(service.Spec.Ports[0].Port)})
@@ -81,14 +81,14 @@ func makeLinkVariables(service *api.Service) []api.EnvVar {
// Docker special-cases the first port.
all = append(all, api.EnvVar{
Name: prefix + "_PORT",
Value: fmt.Sprintf("%s://%s:%d", strings.ToLower(protocol), service.Spec.PortalIP, sp.Port),
Value: fmt.Sprintf("%s://%s:%d", strings.ToLower(protocol), service.Spec.ClusterIP, sp.Port),
})
}
portPrefix := fmt.Sprintf("%s_PORT_%d_%s", prefix, sp.Port, strings.ToUpper(protocol))
all = append(all, []api.EnvVar{
{
Name: portPrefix,
Value: fmt.Sprintf("%s://%s:%d", strings.ToLower(protocol), service.Spec.PortalIP, sp.Port),
Value: fmt.Sprintf("%s://%s:%d", strings.ToLower(protocol), service.Spec.ClusterIP, sp.Port),
},
{
Name: portPrefix + "_PROTO",
@@ -100,7 +100,7 @@ func makeLinkVariables(service *api.Service) []api.EnvVar {
},
{
Name: portPrefix + "_ADDR",
Value: service.Spec.PortalIP,
Value: service.Spec.ClusterIP,
},
}...)
}

View File

@@ -30,8 +30,8 @@ func TestFromServices(t *testing.T) {
{
ObjectMeta: api.ObjectMeta{Name: "foo-bar"},
Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"},
PortalIP: "1.2.3.4",
Selector: map[string]string{"bar": "baz"},
ClusterIP: "1.2.3.4",
Ports: []api.ServicePort{
{Port: 8080, Protocol: "TCP"},
},
@@ -40,8 +40,8 @@ func TestFromServices(t *testing.T) {
{
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"},
PortalIP: "5.6.7.8",
Selector: map[string]string{"bar": "baz"},
ClusterIP: "5.6.7.8",
Ports: []api.ServicePort{
{Name: "u-d-p", Port: 8081, Protocol: "UDP"},
{Name: "t-c-p", Port: 8081, Protocol: "TCP"},
@@ -51,8 +51,8 @@ func TestFromServices(t *testing.T) {
{
ObjectMeta: api.ObjectMeta{Name: "q-u-u-x"},
Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"},
PortalIP: "9.8.7.6",
Selector: map[string]string{"bar": "baz"},
ClusterIP: "9.8.7.6",
Ports: []api.ServicePort{
{Port: 8082, Protocol: "TCP"},
{Name: "8083", Port: 8083, Protocol: "TCP"},
@@ -60,20 +60,20 @@ func TestFromServices(t *testing.T) {
},
},
{
ObjectMeta: api.ObjectMeta{Name: "svrc-portalip-none"},
ObjectMeta: api.ObjectMeta{Name: "svrc-clusterip-none"},
Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"},
PortalIP: "None",
Selector: map[string]string{"bar": "baz"},
ClusterIP: "None",
Ports: []api.ServicePort{
{Port: 8082, Protocol: "TCP"},
},
},
},
{
ObjectMeta: api.ObjectMeta{Name: "svrc-portalip-empty"},
ObjectMeta: api.ObjectMeta{Name: "svrc-clusterip-empty"},
Spec: api.ServiceSpec{
Selector: map[string]string{"bar": "baz"},
PortalIP: "",
Selector: map[string]string{"bar": "baz"},
ClusterIP: "",
Ports: []api.ServicePort{
{Port: 8082, Protocol: "TCP"},
},

View File

@@ -885,7 +885,7 @@ func (kl *Kubelet) getServiceEnvVarMap(ns string) (map[string]string, error) {
// project the services in namespace ns onto the master services
for _, service := range services.Items {
// ignore services where PortalIP is "None" or empty
// ignore services where ClusterIP is "None" or empty
if !api.IsServiceIPSet(&service) {
continue
}

View File

@@ -1260,7 +1260,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8081,
}},
PortalIP: "1.2.3.1",
ClusterIP: "1.2.3.1",
},
},
{
@@ -1270,7 +1270,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8083,
}},
PortalIP: "1.2.3.3",
ClusterIP: "1.2.3.3",
},
},
{
@@ -1280,7 +1280,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8084,
}},
PortalIP: "1.2.3.4",
ClusterIP: "1.2.3.4",
},
},
{
@@ -1290,7 +1290,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8085,
}},
PortalIP: "1.2.3.5",
ClusterIP: "1.2.3.5",
},
},
{
@@ -1300,7 +1300,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8085,
}},
PortalIP: "None",
ClusterIP: "None",
},
},
{
@@ -1319,7 +1319,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8086,
}},
PortalIP: "1.2.3.6",
ClusterIP: "1.2.3.6",
},
},
{
@@ -1329,7 +1329,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8088,
}},
PortalIP: "1.2.3.8",
ClusterIP: "1.2.3.8",
},
},
{
@@ -1339,7 +1339,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8088,
}},
PortalIP: "None",
ClusterIP: "None",
},
},
{
@@ -1349,7 +1349,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Protocol: "TCP",
Port: 8088,
}},
PortalIP: "",
ClusterIP: "",
},
},
}