---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: azure-scheduledevents
  namespace: kube-system
spec:
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 100%
  selector:
    matchLabels:
      app: azure-scheduledevents
  template:
    metadata:
      labels:
        app: azure-scheduledevents
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/path: /metrics
        prometheus.io/port: "8080"
    spec:
      serviceAccountName: azure-scheduledevents
      terminationGracePeriodSeconds: 300
      nodeSelector:
        kubernetes.io/os: linux
      tolerations:
        - effect: NoSchedule
          operator: Exists
      containers:
        - name: azure-scheduledevents
          image: webdevops/azure-scheduledevents-manager:latest
          env:
            - name: AZURE_APPROVE_SCHEDULEDEVENT
              value: "true"
            - name: DRAIN_ENABLE
              value: "true"
            - name: DRAIN_MODE
              value: "kubernetes"
            - name: DRAIN_NOT_BEFORE
              value: "15m"
            - name: KUBE_DRAIN_ARGS
              value: "--force --grace-period=600 --timeout=0s --delete-emptydir-data=true --ignore-daemonsets=true"
            - name: KUBE_NODENAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          securityContext:
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            capabilities:
              drop: ['ALL']
          ports:
            - containerPort: 8080
              name: http-metrics
              protocol: TCP
          resources:
            limits:
              cpu: 1
              memory: 50Mi
            requests:
              cpu: 100m
              memory: 50Mi
