简体   繁体   English

Traefik 忽略 k8s 中的 IngressRoute 和 Ingress 资源

[英]Traefik ignores IngressRoute and Ingress resources in k8s

I deployed Traefik helm chart and created IngressRoute for dashboard and Middleware for Basic Auth, instead of dashboard I see 404 error.我部署了 Traefik helm chart 并为仪表板创建了 IngressRoute,并为基本身份验证创建了中间件,而不是仪表板,我看到了 404 错误。

Ingress also returns 404. Ingress 也返回 404。

IngressRoute and Ingress also don't work with other services IngressRoute 和 Ingress 也不适用于其他服务

Traefik - 2.7.1 k8s - v1.22.8-gke.202 (GKE Autopilot) Traefik - 2.7.1 k8s - v1.22.8-gke.202 (GKE Autopilot)

Helm values:头盔值:

additionalArguments:
  - "--log.level=DEBUG"
  - "--entrypoints.web.http.redirections.entryPoint.to=:443"
  - "--providers.file.filename=/config/dynamic.yaml"

volumes:
  - name: tls-cert
    mountPath: "/certs"
    type: secret
  - name: traefik-config
    mountPath: "/config"
    type: configMap

service:
  spec:
    externalTrafficPolicy: Local
    loadBalancerIP: "xxx.xxx.xxx.xxx"

ingressRoute:
  dashboard:
    enabled: false

Configmap:配置图:

apiVersion: v1
kind: ConfigMap
metadata:
  name: traefik-config
  namespace: ingress
data:
  dynamic.yaml: |
    tls:
      stores:
        default:
          defaultCertificate:
            certFile: '/certs/tls.crt'
            keyFile: '/certs/tls.key'

And IngressRoute:和 IngressRoute:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
  namespace: ingress
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`traefik.example.domain`)
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService
      middlewares:
        - name: admin-auth
          namespace: ingress
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: admin-auth
spec:
  basicAuth:
    namespace: ingress
    secret: ingress-authsecret
---
apiVersion: v1
kind: Secret
metadata:
  name: ingress-authsecret
  namespace: ingress
data:
  users: some-base64-encoded-credentials

Solution:解决方案:

IngressRoute was ignored because no tls configuration was prodided IngressRoute 被忽略,因为没有提供 tls 配置

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
  namespace: ingress
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`traefik.example.domain`)
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService
      middlewares:
        - name: admin-auth
          namespace: ingress
  tls:
    secretName: tls-cert # here

So, I remove default certificate configmap and add tls paramether to dynamic conf因此,我删除了默认证书配置映射并将 tls 参数添加到动态 conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM