---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: traefik
  namespace: loadbalancer
spec:
  selector:
    matchLabels:
      app: traefik
  template:
    metadata:
      labels:
        app: traefik
    spec:
      terminationGracePeriodSeconds: 30
      serviceAccountName: traefik-ingress-controller
      tolerations:
        - key: component
          operator: Equal
          value: k8s_ingress
          effect: NoSchedule
        - key: product
          operator: Equal
          value: infrastructure
          effect: NoSchedule
        - key: service
          operator: Equal
          value: platform
          effect: NoSchedule
        - key: environment
          operator: Equal
          value: production
          effect: NoSchedule

      containers:
        - name: traefik
          image: traefik:v2.1.3
          ports:
            - name: http
              containerPort: 80
              hostPort: 80
            - name: https
              containerPort: 443
              hostPort: 443
            - name: traefik
              containerPort: 8080
              hostPort: 8080
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /ping
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /ping
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          volumeMounts:
            - name: traefik-config
              mountPath: /etc/traefik/traefik.yml
              subPath: traefik.yml
          # resources:
          #   requests:
          #     cpu: 100m
          # memory: 200Mi

      volumes:
        - name: traefik-config
          configMap:
            name: traefik-config
