0

Does the Kubernetes support for DNS SRV lookups allow for a Service using externalName and if so, how to allow a pod access to that record? The use case I have is an externally provided service where a third party defines the port number and I'd like to represent that in the same place as the CNAME, i.e. the k8s Service.

I had go using a simple nslookup query inside a pod with dnsPolicy set to ClusterFirst and it seems to work for the default kubernetes service which is internal:

x nslookup -type=SRV _https._tcp.kubernetes.default.svc
Server: 10.3.0.10
Address: 10.3.0.10#53

_https._tcp.kubernetes.default.svc.cluster.local    service = 10 100 443 kubernetes.default.svc.cluster.local.

But I tried with one of my own Services which uses externalName plus a named port and it cannot be found.

I'm using k8s 1.6.1 and kube-dns 1.9 (admittedly 1.9 is a bit "old", I will upgrade it shortly).

Chris K
  • 29
  • 1
  • 2

1 Answers1

1

The docs says following:

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.

So I don't think it is possible to add ports information in the same service definition.

And when accessing this service your application can do this:

curl k8s_svc_name:third_party_defined_port_number

What is the problem in using that?

surajd
  • 1,627
  • 13
  • 13
  • 1
    Thanks, I had missed that part of the docs (or it got updated). kubectl and the cluster accept an externalName Service with ports defined as of k8s 1.6.2 so it's not disallowed directly. The problem of defining the port like that is I'd either have to keep it in some shared config map that is separate to the service definition or distribute it in the config of each of the apps connecting. I was hoping to store information about the service in a single place single the port can change and I'd prefer it to be discoverable from the service. – Chris K Apr 27 '17 at 01:30