Merge pull request #28239 from ApsOps/kubectl-expose-headless-svc

Automatic merge from submit-queue

Add a flag for `kubectl expose`to set ClusterIP and allow headless services

- Use `--cluster-ip=None` to create a headless service
- Fixes #10294
This commit is contained in:
k8s-merge-robot
2016-08-02 01:18:19 -07:00
committed by GitHub
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{}{