---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: aws-node-termination-handler
  labels:
    app: aws-node-termination-handler
spec:
  updateStrategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLabels:
      app: aws-node-termination-handler
  template:
    metadata:
      labels:
        app: aws-node-termination-handler
    spec:
      volumes:
        - name: "uptime"
          hostPath:
            path: "/proc/uptime"
      priorityClassName: "system-node-critical"
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: "kubernetes.io/os"
                    operator: In
                    values:
                      - linux
                  - key: "kubernetes.io/arch"
                    operator: In
                    values:
                      - amd64
                      - arm64
                      - arm
                  - key: "eks.amazonaws.com/compute-type"
                    operator: NotIn
                    values:
                      - fargate
      serviceAccountName: aws-node-termination-handler
      hostNetwork: true
      dnsPolicy: "ClusterFirstWithHostNet"
      containers:
        - name: aws-node-termination-handler
          image: public.ecr.aws/aws-ec2/aws-node-termination-handler
          imagePullPolicy: IfNotPresent
          securityContext:
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 1000
            runAsGroup: 1000
            allowPrivilegeEscalation: false
          volumeMounts:
            - name: "uptime"
              mountPath: "/proc/uptime"
              readOnly: true
          env:
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: DELETE_LOCAL_DATA
              value: ""
            - name: IGNORE_DAEMON_SETS
              value: ""
            - name: GRACE_PERIOD
              value: ""
            - name: POD_TERMINATION_GRACE_PERIOD
              value: ""
            - name: INSTANCE_METADATA_URL
              value: ""
            - name: NODE_TERMINATION_GRACE_PERIOD
              value: ""
            - name: WEBHOOK_HEADERS
              value: ""
            - name: WEBHOOK_TEMPLATE
              value: ""
            - name: DRY_RUN
              value: "false"
            - name: ENABLE_SPOT_INTERRUPTION_DRAINING
              value: "true"
            - name: ENABLE_SCHEDULED_EVENT_DRAINING
              value: "false"
            - name: ENABLE_REBALANCE_MONITORING
              value: "true"
            - name: ENABLE_REBALANCE_DRAINING
              value: "false"
            - name: CHECK_ASG_TAG_BEFORE_DRAINING
              value: "true"
            - name: MANAGED_ASG_TAG
              value: "aws-node-termination-handler/managed"
            - name: METADATA_TRIES
              value: "3"
            - name: CORDON_ONLY
              value: "false"
            - name: TAINT_NODE
              value: "false"
            - name: JSON_LOGGING
              value: "false"
            - name: LOG_LEVEL
              value: "info"
            - name: WEBHOOK_PROXY
              value: ""
            - name: UPTIME_FROM_FILE
              value: ""
            - name: ENABLE_PROMETHEUS_SERVER
              value: "true"
            - name: PROMETHEUS_SERVER_PORT
              value: "9092"
            - name: ENABLE_PROBES_SERVER
              value: "false"
            - name: PROBES_SERVER_PORT
              value: "8080"
            - name: PROBES_SERVER_ENDPOINT
              value: "/healthz"
          resources:
            limits:
              cpu: 100m
              memory: 128Mi
            requests:
              cpu: 50m
              memory: 64Mi
          ports:
            - containerPort: 9092
              hostPort: 9092
              name: http-metrics
              protocol: TCP
      nodeSelector:
        kubernetes.io/os: linux
      tolerations:
        - operator: Exists
