{{- if and .Values.deployment.enabled (eq .Values.deployment.kind "DaemonSet") -}}
  {{- with .Values.additionalArguments -}}
    {{- range . -}}
      {{- if contains ".acme." . -}}
        {{- fail (printf "ACME functionality is not supported when running Traefik as a DaemonSet") -}}
      {{- end -}}
    {{- end -}}
  {{- end -}}
  {{- if eq (default .Chart.AppVersion .Values.image.tag) "latest" }}
    {{- fail "\n\n ERROR: latest tag should not be used" }}
  {{- end }}
  {{- if eq (.Values.updateStrategy.type) "RollingUpdate" }}
    {{- if and (lt .Values.updateStrategy.rollingUpdate.maxUnavailable 1.0) (.Values.hostNetwork)  }}
      {{- fail "maxUnavailable should be greater than 1 when using hostNetwork." }}
    {{- end }}
  {{- end }}

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: {{ template "traefik.fullname" . }}
  namespace: {{ template "traefik.namespace" . }}
  labels:
  {{- include "traefik.labels" . | nindent 4 }}
  {{- with .Values.deployment.labels }}
  {{- toYaml . | nindent 4 }}
  {{- end }}
  annotations:
  {{- with .Values.deployment.annotations }}
  {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  selector:
    matchLabels:
      {{- include "traefik.labelselector" . | nindent 6 }}
  updateStrategy: {{ toYaml .Values.updateStrategy | nindent 4 }}
  minReadySeconds: {{ .Values.deployment.minReadySeconds }}
  {{- if .Values.deployment.revisionHistoryLimit }}
  revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }}
  {{- end }}
  template: {{ template "traefik.podTemplate" . }}
{{- end -}}
