pagislav
pagislav

Reputation: 163

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.

Ingress also returns 404.

IngressRoute and Ingress also don't work with other services

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:

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

Upvotes: 0

Views: 1110

Answers (1)

pagislav
pagislav

Reputation: 163

Solution:

IngressRoute was ignored because no tls configuration was prodided

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

Upvotes: 2

Related Questions