Custom URL name for internal services

11/6/2018

I have a Kubernetes cluster. Some internal services (such as Kubernetes Dashboard) are only accessible via an OpenVPN instance I set up.

Per default kube-dns resolves services like: http://{service-name}.{namespace-name}.svc.cluster.local

For example http://kubernetes-dashboard.default.svc.cluster.local works beautifully. How can I add custom DNS entries to make these services for example accessible via http://kubernetes-dashboard.mycompany ?

-- Hedge
kube-dns
kubernetes

1 Answer

11/6/2018

I'm not sure if this is possible with kubedns, but it is with coreDNS if you're on 1.11+.

Custom DNS Entries For Kubernetes

If that's not an option you could run your own lightweight DNS service with your custom rules inside the cluster and set it up as a "stub domain" in the kubedns configMap as described here.

apiVersion: v1
kind: ConfigMap
  metadata:
    name: kube-dns
    namespace: kube-system
data:
  stubDomains: |
    {"dashboard.mycompany": ["1.2.3.4"]}

In this case you'd want to change 1.2.3.4 to the ClusterIP of your new DNS server.

-- switchboard.op
Source: StackOverflow