Add a kubectl expose flag to give ClusterIP

- Use `--cluster-ip=None` to create a headless service
- Fixes #10294
This commit is contained in:
Aman
2016-06-30 02:11:08 +05:30
parent 3814809f07
commit e9e06d6826
5 changed files with 134 additions and 0 deletions

View File

@@ -303,6 +303,66 @@ func TestGenerateService(t *testing.T) {
},
},
},
{
generator: ServiceGeneratorV2{},
params: map[string]interface{}{
"selector": "foo=bar,baz=blah",
"name": "test",
"port": "80",
"protocol": "TCP",
"container-port": "1234",
"cluster-ip": "10.10.10.10",
},
expected: api.Service{
ObjectMeta: api.ObjectMeta{
Name: "test",
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"foo": "bar",
"baz": "blah",
},
Ports: []api.ServicePort{
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
},
},
ClusterIP: "10.10.10.10",
},
},
},
{
generator: ServiceGeneratorV2{},
params: map[string]interface{}{
"selector": "foo=bar,baz=blah",
"name": "test",
"port": "80",
"protocol": "TCP",
"container-port": "1234",
"cluster-ip": "None",
},
expected: api.Service{
ObjectMeta: api.ObjectMeta{
Name: "test",
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"foo": "bar",
"baz": "blah",
},
Ports: []api.ServicePort{
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
},
},
ClusterIP: api.ClusterIPNone,
},
},
},
{
generator: ServiceGeneratorV1{},
params: map[string]interface{}{