Skip to content

Traefik — Ingress Controller ​

Traefik is the ingress controller for this cluster. It handles all inbound HTTP/HTTPS traffic, TLS termination, and routing to backend services.

k3s ships with Traefik by default, but this repo disables the built-in Traefik (--disable=traefik) and installs it via Helm for full configuration control.


What Traefik does here ​

ResponsibilityDetail
Ingress controllerRoutes traffic to services via IngressRoute CRDs
TLS terminationHandles HTTPS using certificates from cert-manager
DashboardSecured admin UI at DASHBOARD_DOMAIN
MetricsExposes Prometheus metrics on port 9100
Access logsJSON-formatted access logs

Helm install ​

Traefik is installed from the platform-traefik wrapper chart, which pins the upstream traefik subchart (and so the proxy version) in its Chart.yaml:

bash
helm upgrade --install traefik oci://ghcr.io/kevindebenedetti/charts/platform-traefik \
  --version <k3s-lab release, e.g. 0.24.1> \
  --namespace ingress \
  --create-namespace \
  --set 'traefik.service.spec.externalIPs={<server public IP>}'

traefik.service.spec.externalIPs pins the LoadBalancer Service to the server node's public IP. The Service settings live under service.spec: since subchart 42.4.0 the chart's values schema rejects keys placed directly under service (service.type, service.externalIPs), which older versions silently ignored. The subchart version, the deployed proxy version and the advisory history are in the chart README.


Values explained (charts/platform-base/values.yaml) ​

EntryPoints ​

EntryPointPortExposedPurpose
web800080HTTP traffic
websecure8443443HTTPS + TLS
metrics9100NoInternal metrics endpoint

No global HTTP→HTTPS redirect. A global redirect on the web entrypoint would intercept cert-manager's HTTP-01 ACME challenge before the solver can respond, breaking TLS issuance. Use a per-route redirectScheme middleware instead.

TLS hardening ​

TLS 1.0 and 1.1 are disabled. Only strong cipher suites are allowed:

yaml
tlsOptions:
  default:
    minVersion: VersionTLS12
    cipherSuites:
      - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
      - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
      - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305
      - TLS_AES_128_GCM_SHA256
      - TLS_AES_256_GCM_SHA384
      - TLS_CHACHA20_POLY1305_SHA256
    sniStrict: true

Security context ​

Traefik runs as a non-root user (runAsUser: 65532) with a read-only filesystem and dropped capabilities (except NET_BIND_SERVICE for low ports).

Prometheus metrics ​

Traefik serves its Prometheus metrics on the metrics entry point (port 9100, path /metrics).

The chart renders no ServiceMonitor: traefik.metrics.prometheus.serviceMonitor.enabled stays at the subchart's default, false, so the kube-prometheus-stack Prometheus Operator does not discover Traefik on its own. A Traefik-only cluster has no monitoring.coreos.com CRDs, and the subchart refuses to render a ServiceMonitor without them.

To have Prometheus scrape Traefik, turn it on in the values you install the chart with:

yaml
traefik:
  metrics:
    prometheus:
      # The ServiceMonitor selects this dedicated `traefik-metrics` Service.
      service:
        enabled: true
      serviceMonitor:
        enabled: true
        # The label your Prometheus selects ServiceMonitors by. With
        # kube-prometheus-stack's defaults it is the Helm release name of
        # that chart; platform-security's Kyverno ServiceMonitor uses the same.
        additionalLabels:
          release: prometheus

The subchart fails the render (You have to deploy monitoring.coreos.com/v1 first) when the Prometheus Operator CRDs are not installed yet. Install platform-monitoring first, or set traefik.metrics.prometheus.disableAPICheck: true when the CRDs arrive in the same sync.


Dashboard ​

The Traefik dashboard is exposed via a secured IngressRoute at DASHBOARD_DOMAIN.

Create the BasicAuth secret (run once) ​

bash
task deploy:dashboard-secret

This runs:

bash
kubectl create secret generic traefik-dashboard-auth \
  --from-literal=users="$(htpasswd -nb admin <DASHBOARD_PASSWORD>)" \
  -n ingress

Username is always admin. Password is set via DASHBOARD_PASSWORD in .env.

IngressRoute manifest ​

The dashboard manifest is managed via ArgoCD or your consuming repo's platform/ directory. It creates:

  1. dashboard-basicauth Middleware — enforces HTTP Basic Authentication
  2. dashboard-redirect-scheme Middleware — HTTP → HTTPS redirect
  3. traefik-dashboard IngressRoute — routes DASHBOARD_DOMAIN/dashboard and /api to api@internal
  4. traefik-dashboard-tls Certificate — cert-manager issues a Let's Encrypt certificate
yaml
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard
  namespace: ingress
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`${DASHBOARD_DOMAIN}`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))
      kind: Rule
      middlewares:
        - name: dashboard-basicauth
          namespace: ingress
      services:
        - name: api@internal
          kind: TraefikService
  tls:
    secretName: traefik-dashboard-tls

Deploying your own services ​

To expose a service via Traefik, create an IngressRoute:

yaml
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: my-app
  namespace: apps
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`app.example.com`)
      kind: Rule
      services:
        - name: my-app-svc
          port: 80
  tls:
    secretName: my-app-tls
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: my-app-tls
  namespace: apps
spec:
  secretName: my-app-tls
  issuerRef:
    name: letsencrypt-production
    kind: ClusterIssuer
  dnsNames:
    - app.example.com

See Kustomize components for a complete example.


References ​