Search code examples
kuberneteskubernetes-ingresstraefiktraefik-ingress

How can i get the traefik controller config and some question about ingress path


My ingress controller is traefik, I want to configure a domain name in ingress with multiple paths for different services.but When I configured and reapply it. I can only access the service corresponding to the root of the domain name, while the other services corresponding to the path are all 404 there is my ingress config:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  namespace: runsdata
  annotations:
    kubernetes.io/ingress.class: "traefik"
spec:
  tls:
  - secretName: traefik-cert
  rules:
  - host: testenv.runsdata.com
    http:
      paths:
      - backend:
          serviceName: nginx-svc
          servicePort: 8088
  - host: testenv.runsdata.com
    http:
      paths:
      - backend:
          serviceName: traefik-web-ui
          servicePort: 8006
        path: /traefik

I can access the nginx-svc by the url:https://testenv.runsdata.com:12840/ . But I can't access the traefik-web-ui service by the url: https://testenv.runsdata.com:12840/traefik. Is there anything wrong with my configuration. Another question is how can I see the rules that ingress maps to traefik.I want to see if the mapping is correct. I exec the command kubectl exec -it traefik-ingress-controller-5c5dc68dd4-jxk84 /bin/bash. I wanted to go inside the container and have a look.But it seems that there is no command installed, the command does not exist


Solution

  • Since traefik USES the host route by default, So we just only need to specify it use the path route in annotations like below

    annotations:
        kubernetes.io/ingress.class: "traefik"
        traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip