kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: traefik
  labels:
    app: traefik
spec:
  selector:
    matchLabels:
      app: traefik
  template:
    metadata:
      labels:
        app: traefik
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/path: /metrics
        prometheus.io/port: '8081'
    spec:
      serviceAccountName: traefik
      terminationGracePeriodSeconds: 60
      containers:
      - image: registry.homelab.dsb.dev/library/traefik:v2.3.6
        name: traefik
        env:
          - name: TRAEFIK_PILOT_TOKEN
            valueFrom:
              secretKeyRef:
                key: pilot.token
                name: traefik
        ports:
        - name: http
          containerPort: 80
          hostPort: 80
        - name: https
          containerPort: 443
          hostPort: 443
        - name: admin
          containerPort: 8080
          hostPort: 8080
        securityContext:
          capabilities:
            drop:
              - ALL
            add:
              - NET_BIND_SERVICE
        args:
        - --configFile=/config/traefik.yaml
        volumeMounts:
          - mountPath: /config/traefik.yaml
            name: traefik
            subPath: traefik.yaml
          - mountPath: /config/common/middleware.yaml
            name: traefik
            subPath: middleware.yaml
        resources:
          limits:
            memory: 512Mi
            cpu: "1"
        livenessProbe:
          httpGet:
            port: 8082
            path: /ping
        readinessProbe:
          httpGet:
            port: 8082
            path: /ping
      volumes:
        - name: traefik
          configMap:
            name: traefik
