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

The service with IP as ExternalName did not work #2164

Closed
zyxbest opened this issue Oct 8, 2018 · 7 comments
Closed

The service with IP as ExternalName did not work #2164

zyxbest opened this issue Oct 8, 2018 · 7 comments
Labels
kubernetes off topic Not related to CoreDNS

Comments

@zyxbest
Copy link

zyxbest commented Oct 8, 2018

My Env

kubernetes v1.11.3 (HA cluster) + k8s.gcr.io/coredns:1.1.3 + aws

What I did

  1. Create tests service like this
---
kind: Service
apiVersion: v1
metadata:
  name: test-domain-service
spec:
  type: ExternalName
  externalName: kubernetes.io
---
kind: Service
apiVersion: v1
metadata:
  name: test-ip-service
spec:
  type: ExternalName
  externalName: 104.198.14.52
  1. Enter (kubectl exec) one pod to access these services
    image

What I'm supposed to see (also works with kube-dns in kubeadm v1.6)

Kubernetes can resolve this two service as well

image

What's more

Actually, I want to create the service below:

---
kind: Service
apiVersion: v1
metadata:
  name: test-domain-service
spec:
  type: ExternalName
  externalName: ip-10-10-10-204.xxxxxx.compute.internal
---
kind: Service
apiVersion: v1
metadata:
  name: test-ip-service
spec:
  type: ExternalName
  externalName: 10.10.10.204

As you see, they are aws EC2 private DNS name and private IP of one machine, the same result as the experiment.

My question

Is there any feature or design that coreDns can't resolve service which forwards to an ip address?
Similar question : https://discuss.kubernetes.io/t/service-externalname-ip/494/5

@chrisohaver
Copy link
Member

It is unclear what you expect. In your example, you say that "kubernetes can resolve these two service...", but in the graphic that follows it, both results are "Not Found" ...

It's odd that an IP is allowed in the "externalName" field. The k8s documentation I found seems to infer that a IP in the field would not make sense:

ExternalName: Maps the service to the contents of the externalName field (e.g. foo.bar.example.com), by returning a CNAME record with its value. No proxying of any kind is set up. This requires version 1.7 or higher of kube-dns.

... AFIAK, a CNAME value cant be an IP.

If you want a service that resolves to a statically defined ip address, you could ...

  • create a headless service
  • then create a statically defined endpoint for that service that contains the ip address.

e.g.

apiVersion: v1
kind: Service
metadata:
  name: gdns
  namespace: default
spec:
  clusterIP: None
  ports:
  - name: dns
    port: 53
    protocol: UDP
---
kind: Endpoints
apiVersion: v1
metadata:
  name: gdns
  namespace: default
subsets:
  - addresses:
      - ip: 8.8.8.8
    ports:
      - port: 53
        name: dns
        protocol: UDP

@zyxbest
Copy link
Author

zyxbest commented Oct 9, 2018

Thanks for your response!

  1. I'm sorry that this case is kinda confusing, what I want to show that Service returns 404 differs from Can't resolve the service, that is, domain-service should perform the same as ip-service .
  2. Anyway, now I get the point , thanks again for the explanation~~ The config works well, It helps!
  3. BTW, In my past experience, the ip-valued-CNAME always work in kubeadm v1.6 , It looks like some version issues : )

@zyxbest zyxbest closed this as completed Oct 9, 2018
@miekg
Copy link
Member

miekg commented Oct 9, 2018 via email

@Yensan
Copy link

Yensan commented Jun 24, 2022

@chrisohaver
You give a really good example to show how to use Headless Service.
I want ask you a question, what is externalName for? I read the doc, then, toasted, confused.

@chrisohaver
Copy link
Member

ExternalName creates a locally named alias to a service name outside of the cluster.
Eg

example.default.svc.cluster.local => some.service.example.com

@Yensan
Copy link

Yensan commented Jun 25, 2022

ExternalName creates a locally named alias to a service name outside of the cluster. Eg

example.default.svc.cluster.local => some.service.example.com

Yes. All people say in this accent...While, many people failed using this way to fetch other domain's service. For example, I must use github.com account auth service to login my web.
But the doc said, the Headless just like you write above, is the good practice.
What makes me confusing is this.

@chrisohaver chrisohaver added the off topic Not related to CoreDNS label Jun 25, 2022
@coredns coredns locked as off-topic and limited conversation to collaborators Jun 25, 2022
@chrisohaver
Copy link
Member

chrisohaver commented Jun 25, 2022

Perhaps folks in the kubernetes-novice slack channel can explain better than me.

https://slack.k8s.io/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kubernetes off topic Not related to CoreDNS
Projects
None yet
Development

No branches or pull requests

4 participants