Access service on subdomain in Kubernetes
Solution 1:
Here is the answer to all these people that see it after 5 years since the question got asked.
Tech got better and now we have ingress in k8s :D.
To make use of subdomains, deploy ingress controller e.g. nginx ingress controller
and create an ingress object:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
spec:
rules:
- host: "simple-nginx.domain.com"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: simple-nginx
port:
number: 80
Now all that is left to do, is to create a dns record for *.domain.com
and point it to the ingress IP seen in ADDRESS column.
$ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress <none> simple-nginx.domain.com xxx.yyy.zzz.kkk 80 2d20h