Populate endpoints and allow ports with headless service

This commit is contained in:
xiangpengzhao
2017-06-09 23:22:37 +08:00
parent 11b5956f7a
commit 9e31eb280a
8 changed files with 161 additions and 76 deletions

View File

@@ -57,13 +57,6 @@ func TestServiceBasicGenerate(t *testing.T) {
serviceType: api.ServiceTypeClusterIP,
expectErr: true,
},
{
name: "clusterip-none and port mapping",
tcp: []string{"456:9898"},
clusterip: "None",
serviceType: api.ServiceTypeClusterIP,
expectErr: true,
},
{
name: "clusterip-none-wrong-type",
tcp: []string{},
@@ -88,6 +81,23 @@ func TestServiceBasicGenerate(t *testing.T) {
},
expectErr: false,
},
{
name: "clusterip-none-and-port-mapping",
tcp: []string{"456:9898"},
clusterip: "None",
serviceType: api.ServiceTypeClusterIP,
expected: &api.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "clusterip-none-and-port-mapping",
Labels: map[string]string{"app": "clusterip-none-and-port-mapping"},
},
Spec: api.ServiceSpec{Type: "ClusterIP",
Ports: []api.ServicePort{{Name: "456-9898", Protocol: "TCP", Port: 456, TargetPort: intstr.IntOrString{Type: 0, IntVal: 9898, StrVal: ""}, NodePort: 0}},
Selector: map[string]string{"app": "clusterip-none-and-port-mapping"},
ClusterIP: "None", ExternalIPs: []string(nil), LoadBalancerIP: ""},
},
expectErr: false,
},
{
name: "loadbalancer-ok",
tcp: []string{"456:9898"},