Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExternalName type service cannot be created if without spec.ports. #34394

Closed
chengzhang1016 opened this issue Oct 8, 2016 · 8 comments
Closed

Comments

@chengzhang1016
Copy link

What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.): external service

Kubernetes version (use kubectl version):
v1.5.0-alpha.0.2084+162d80eced3989

What happened:
ExternalName type service cannot be created if without spec.ports.

How to reproduce it (as minimally and precisely as possible):
Create a ExternalName type service: kubectl create -f ExternalName type service

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "my-service"
    },
    "spec": {
        "type": "ExternalName",
        "externalName": "my.database.example.com"
    }
}

Actual results:
ExternalName type service created failed.

# kubectl create -f externalname-service.json
error: error validating "externalname-service.json": error validating data: field ports: is required; if you choose to ignore these errors, turn validation off with --validate=false

Expected results:
Service should be created successful.

Anything else do we need to know:
You can refer to the docs about externalname type service: https://github.com/kubernetes/kubernetes.github.io/blob/release-1.4/docs/user-guide/services/index.md
The docs indicated that An ExternalName service is a special case of service that does not have selectors. It does not define any ports or endpoints. Rather, it serves as a way to return an alias to an external service residing outside the cluster.

@mdshuai
Copy link

mdshuai commented Oct 8, 2016

@derekwaynecarr @therc

@adohe-zz
Copy link

adohe-zz commented Oct 8, 2016

this should be some validation error.

@chengzhang1016
Copy link
Author

@mdshuai @derekwaynecarr @therc
I opened this issue base on below three merged PRs:
kubernetes/website#1063
#30599
#30931

@thaniyarasu
Copy link

This is working .

{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "my-service"
},
"spec": {
"type": "ExternalName",
"externalName": "my.database.example.com",
"ports": [{ "port": 3000 }]
}
}

@chengzhang1016
Copy link
Author

@thaniyarasu No. My means is that ExternalName type service cannot be created if without spec.ports.
You can try again via your josn without "ports": [{ "port": 3000 }]

You can refer to the docs about externalname type service: https://github.com/kubernetes/kubernetes.github.io/blob/release-1.4/docs/user-guide/services/index.md
The docs indicated that An ExternalName service is a special case of service that does not have selectors. It does not define any ports or endpoints. Rather, it serves as a way to return an alias to an external service residing outside the cluster.

@chengzhang1016
Copy link
Author

@thaniyarasu ExternalName type service should be created successful without spec.ports by document: https://github.com/kubernetes/kubernetes.github.io/blob/release-1.4/docs/user-guide/services/index.md

@adohe-zz
Copy link

@chengzhang1016 I opened a PR #34789 to create ExternalName service through kubectl, you may want to take a look.

@chengzhang1016
Copy link
Author

@hodovska Verified. Thanks for your fixing.

perotinus pushed a commit to kubernetes-retired/cluster-registry that referenced this issue Sep 2, 2017
Automatic merge from submit-queue

API v1: do not require ports for all types of services

Ports values had to be specified for all types of services but object with service type "ExternalName" does't define ports. That's why we had to remove required condition.
Presence of ports in service types where ports are actually required is verified here: 
https://github.com/kubernetes/kubernetes/blob/master/pkg/api/validation/validation.go#L2439

For more information about ExternalName services see:
http://kubernetes.io/docs/user-guide/services/#services-without-selectors

Fixes kubernetes/kubernetes#34394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants