Kubernetes Ingress for same host in different namespace

7/27/2017

I have two services, tea and coffee, each is in their own namespace, I would like domain.com to go to the tea service and domain.com/coffee to go to coffee.

As each is in a namespace I have had to make two pieces of ingress, but when I try to apply them I get the error MAPPING Path '/coffee' already defined in another Ingress rule.

My two pieces of ingress look like the following:

Tea:

kind: Ingress
apiVersion: extensions/v1beta1
spec:
  tls:
  - hosts:
    - domain.com
    secretName: tea-tls
  rules:
  - host: domain.com
    http:
      paths:
      - path: /
        backend:
          serviceName: tea
          servicePort: 80

and Coffee:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: coffee
  namespace: coffee
spec:
  tls:
  - hosts:
    - domain.com
    secretName: coffee}-tls
  rules:
  - host: domain.com
    http:
      paths:
      - path: /coffee
        backend:
          serviceName: coffee
          servicePort: 80
      - path: /coffee/*
        backend:
          serviceName: coffee
          servicePort: 80
-- Simon I
kubernetes
kubernetes-helm

2 Answers

7/30/2017

I guess the problem isn't having tea and coffee, but defining the coffee path twice in the coffee ingress. According to https://kubernetes.io/docs/concepts/services-networking/ingress/#simple-fanout I would assume that you only need the /coffee path, and can delete the /coffee/* path.

-- slintes
Source: StackOverflow

7/27/2017

According to https://github.com/kubernetes/kubernetes/issues/17088, the voyager ingress controller can do the trick. Example (taken from the link):

apiVersion: voyager.appscode.com/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  namespace: foo
spec:
  rules:
  - host: foo.bar.com
    http:
      paths:
      - backend:
          serviceName: s1.bar # serviceName.Namespace
          servicePort: '80'
-- Javier Salmeron
Source: StackOverflow