Traefik 向除仪表板以外的所有地方显示 404 - Metallb

Traefik shows 404 to everywhere except dashboard - Metallb

我尝试使用 traefik 设置入口,但没有成功。我不会仅仅使用 TLS 端口 80。我有一个端口为 8080 的服务。如果我从集群内部 curl 到该服务,它运行良好。我得到 HTTP/200。但如果我从外部连接到他的路径,它就不起作用了。 Traefik 仪表板在端口 8080

上运行良好

我正在使用以下设置

Traefik:1.7.7

kind: Deployment
apiVersion: apps/v1
metadata:
  name: traefik-ingress-controller
  namespace: default
  labels:
    k8s-app: traefik-ingress-lb
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: traefik-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: traefik-ingress-lb
        name: traefik-ingress-lb
    spec:
      serviceAccountName: traefik-ingress-controller
      terminationGracePeriodSeconds: 60
      containers:
      - image: traefik:v1.7.7
        name: traefik-ingress-lb
        ports:
        - name: http
          containerPort: 80
        - name: admin
          containerPort: 8080
        args:
        - --api
        - --web
        - --kubernetes
        - --logLevel=DEBUG

---
kind: Service
apiVersion: v1
metadata:
  name: traefik-ingress-service
  namespace: default
  annotations:
    metallb.universe.tf/address-pool: mmas-ip-space
spec:
  selector:
    k8s-app: traefik-ingress-lb
  ports:
    - protocol: TCP
      port: 80
      name: web
    - protocol: TCP
      port: 8080
      name: admin
  type: LoadBalancer

我在端口 8080 上有一个 运行 服务,我为它创建了一个入口规则。这是一个测试服务

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: webmust-ing
  namespace: default
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
    - http:
        paths:
        - path: /helloservice
          backend:
            serviceName: hellok8s-service
            servicePort: 8080

我通过 curl 到 /helloservice 或尝试从浏览器打开得到 404

curl -v http://10.24.33.32/helloservice
curl -v http://10.24.33.32:8080/helloservice

我如果直接在集群内 curl 到服务的 ip 地址,我得到 200/OK

curl -v http://10.100.168.2:8080

NAME                      TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                       AGE
hellok8s-service          ClusterIP      10.100.168.2     <none>        8080/TCP                      5d7h

猫helloservice.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hellok8s-deployment
  labels:
    app: hellok8s
spec:
  selector:
    matchLabels:
      app: hellok8s
  template:
    metadata:
      labels:
        app: hellok8s
    spec:
      containers:
      - name: hellok8s
        image: docker.io/rlkamradt/hellok8s:latest
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: hellok8s-service
spec:
  type: ClusterIP
  selector:
    app: hellok8s
  ports:
  - port: 8080
    targetPort: 8080

最后,我通过以下入口更改解决了问题。

annotations: 
    ingress.kubernetes.io/protocol: http 
    traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip