Kubernetes internal wildcard DNS record

5/22/2019

I'd like to create a wildcard DNS record that maps to a virtual IP inside my k8s cluster. This is because I want requests from my pods to any subdomain of a given name to map to a specific set of endpoints. I.e. requests from:

something.my-service.my-namespace.svc.cluster.local
something-else.my-service.my-namespace.svc.cluster.local
any-old-thing-my-pod-came-up-with.my-service.my-namespace.svc.cluster.local

to all resolve to the same virtual IP, and therefore to the same cluster (i.e. I would like these requests to be routed to endpoints in the same way a service does).

I've seen some other solutions that involve creating and modifying the cluster DNS service (i.e. kube-dns or CoreDNS) config. This doesn't work for me- the main reason I'm asking this question is to achieve declarative config.

What I've tried:

  • Service .metadata.name: '*.my-service'. Failed because '*.my-service' is not a valid service name.
  • Service .spec.ports.name: '*'. Not a valid port name.

Not an option:

-- mkingston
kubernetes

1 Answer

5/22/2019

wild card dns is not supported for kubernetes services. what you can do is front the service with an ingress controller. with ingress you can use wild card dns. refer the below PR

https://github.com/kubernetes/kubernetes/pull/29204

-- P Ekambaram
Source: StackOverflow