Kubernetes Ingress controllers for wildcard url mapping

6/25/2016

I need for each of my users to access a service at a custom url eg. abccompany.mycloudapp.com , each service being a kubernetes service I'm looking at ingress controllers but I need a way to use a wildcard host field and somehow read the value into the path: and service: fields ; here's a sample ingress controller of what I have in mind:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: test
spec:
 rules:
 - host: *.bar.com
   http:
     paths:
     - path: /{{ value of * in * .bar.com }}
       backend:
         serviceName: {{value of * in *.bar.com }}Svc
         servicePort: 80
-- Jonathan
kubernetes
nginx

1 Answer

6/26/2016

If you use the stock controllers you will be able to switch on hostname and go to different backends services. It sounds like you don't want to enumerate all the subdomains -> service mappings, in which case you probably need to write your own controller that writes out an nginx config that uses $http_host in the appropriate proxy_pass or redirect lines. Give it a shot (https://github.com/kubernetes/contrib/tree/master/ingress/controllers) and file bugs in that same repo if you need help.

-- Prashanth B
Source: StackOverflow