Skip to content

[BUG]: Traefik annotation antipattern #185

@hrabalvojta

Description

@hrabalvojta

This small antipatern was crashing deployment via fluxcd. Due differences in Traefik entrypoint. Temporary fixed with post-render.

annotations:
traefik.ingress.kubernetes.io/router.middlewares: {{ .Release.Namespace }}-strip-prefix@kubernetescrd
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/timeouts.idle: "3600s"
traefik.ingress.kubernetes.io/timeouts.connect: "3600s"
traefik.ingress.kubernetes.io/timeouts.read: "3600s"
traefik.ingress.kubernetes.io/timeouts.write: "3600s"

Parameterization: Instead of hardcoding the entrypoint (web), consider making it configurable via Helm values, which makes your chart more reusable. Post render modification are not required.

annotations:
  traefik.ingress.kubernetes.io/router.middlewares: {{ .Values.global.ingress.traefik.middleware | default (printf "%s-strip-prefix@kubernetescrd" .Release.Namespace) }}
  traefik.ingress.kubernetes.io/router.entrypoints: {{ .Values.global.ingress.traefik.entrypoints | default "web" }}
  {{- with .Values.global.ingress.traefik.timeouts }}
  {{- range $type, $value := . }}
  traefik.ingress.kubernetes.io/timeouts.{{ $type }}: "{{ $value }}"
  {{- end }}
  {{- end }}
global:
  ingress:
    traefik:
      middleware: ""
      entrypoints: web
      timeouts:
        idle: "3600s" 
        connect: "3600s" 
        read: "3600s" 
        write: "3600s" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions