Point traefik ingress at different paths with different services under the same host in Kubernetes

5/18/2020

I have separate services that point to separate services within my cluster. I have a singular ingress set up, that points to a url, with 3 path objects, /, /path1, and path2. All 3 paths point at separate services. However, when I go to any path, it automatically points to the service from /. I have tried rewrite target, which doesn't seem to make much of a difference. Is there something else I need to do to fix this?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/auth-response-headers: X-Forwarded-User, X-Auth-User, X-Secret
    ingress.kubernetes.io/auth-type: forward
    ingress.kubernetes.io/auth-url: http://traefik-forward-auth-svc.ingress.svc.cluster.local:4181
  name: ingress1
  namespace: dev
spec:
  rules:
  - host: myurl.com
    http:
      paths:
      - backend:
          serviceName: service
          servicePort: 80
        path: /
      - backend:
          serviceName: service1
          servicePort: 80
        path: /path1
      - backend:
          serviceName: service2
          servicePort: 80
        path: /path2
Name:              service1
Namespace:         dev
Labels:            <none>
Annotations:       <none>
Selector:          app=deployment1
Type:              ClusterIP
IP:                *ip here*
Port:              http  80/TCP
TargetPort:        80/TCP
Endpoints:         192.168.159.95:80
Session Affinity:  None
Events:            <none>


Name:              service2
Namespace:         dev
Labels:            <none>
Annotations:       <none>
Selector:          app=deployment2
Type:              ClusterIP
IP:                *ip here*
Port:              http  80/TCP
TargetPort:        80/TCP
Endpoints:         192.168.134.76:80
Session Affinity:  None
Events:            <none>
-- Sheen
kubernetes
kubernetes-ingress
traefik

0 Answers