kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: ebs-csi-node-windows
  namespace: kube-system
  labels:
    {{- include "aws-ebs-csi-driver.labels" . | nindent 4 }}
spec:
  selector:
    matchLabels:
      app: ebs-csi-node
      {{- include "aws-ebs-csi-driver.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app: ebs-csi-node
        {{- include "aws-ebs-csi-driver.labels" . | nindent 8 }}
      {{- if .Values.node.podAnnotations }}
      annotations: {{ toYaml .Values.node.podAnnotations | nindent 8 }}
      {{- end }}
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: eks.amazonaws.com/compute-type
                operator: NotIn
                values:
                - fargate
      nodeSelector:
        kubernetes.io/os: windows
        {{- with .Values.node.nodeSelector }}
{{ toYaml . | indent 8 }}
        {{- end }}
      serviceAccountName: {{ .Values.serviceAccount.node.name }}
      priorityClassName: {{ .Values.node.priorityClassName | default "system-cluster-critical" }}
      tolerations:
        {{- if .Values.node.tolerateAllTaints }}
        - operator: Exists
        {{- else }}
        - key: CriticalAddonsOnly
          operator: Exists
        - operator: Exists
          effect: NoExecute
          tolerationSeconds: 300
        {{- end }}
        {{- with .Values.node.tolerations }}
{{ toYaml . | indent 8 }}
        {{- end }}
      containers:
        - name: ebs-plugin
          image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
          args:
            - node
            - --endpoint=$(CSI_ENDPOINT)
            {{- if .Values.volumeAttachLimit }}
            - --volume-attach-limit={{ .Values.volumeAttachLimit }}
            {{- end }}
            - --logtostderr
            - --v=5
          env:
            - name: CSI_ENDPOINT
              value: unix:/csi/csi.sock
{{- if .Values.proxy.http_proxy }}
            - name: HTTP_PROXY
              value: {{ .Values.proxy.http_proxy | quote }}
            - name: HTTPS_PROXY
              value: {{ .Values.proxy.http_proxy | quote }}
            - name: NO_PROXY
              value: {{ .Values.proxy.no_proxy | quote }}
{{- end }}
          volumeMounts:
            - name: kubelet-dir
              mountPath: C:\var\lib\kubelet
              mountPropagation: "None"
            - name: plugin-dir
              mountPath: C:\csi
            - name: csi-proxy-disk-pipe
              mountPath: \\.\pipe\csi-proxy-disk-v1beta2
            - name: csi-proxy-volume-pipe
              mountPath: \\.\pipe\csi-proxy-volume-v1beta2
            - name: csi-proxy-filesystem-pipe
              mountPath: \\.\pipe\csi-proxy-filesystem-v1beta1
          ports:
            - name: healthz
              containerPort: 9808
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /healthz
              port: healthz
            initialDelaySeconds: 10
            timeoutSeconds: 3
            periodSeconds: 10
            failureThreshold: 5
          {{- if .Values.node.resources }}
          {{- with .Values.node.resources }}
          resources: {{ toYaml . | nindent 12 }}
          {{- end }}
          {{- else }}
          {{- with .Values.resources }}
          resources: {{ toYaml . | nindent 12 }}
          {{- end }}
          {{- end }}
        - name: node-driver-registrar
          image: {{ printf "%s:%s" .Values.sidecars.nodeDriverRegistrarImage.repository .Values.sidecars.nodeDriverRegistrarImage.tag }}
          args:
            - --csi-address=$(ADDRESS)
            - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
            - --v=5
          env:
            - name: ADDRESS
              value: unix:/csi/csi.sock
            - name: DRIVER_REG_SOCK_PATH
              value: C:\var\lib\kubelet\plugins\ebs.csi.aws.com\csi.sock
{{- if .Values.proxy.http_proxy }}
            - name: HTTP_PROXY
              value: {{ .Values.proxy.http_proxy | quote }}
            - name: HTTPS_PROXY
              value: {{ .Values.proxy.http_proxy | quote }}
            - name: NO_PROXY
              value: {{ .Values.proxy.no_proxy | quote }}
{{- end }}
          volumeMounts:
            - name: plugin-dir
              mountPath: C:\csi
            - name: registration-dir
              mountPath: C:\registration
          {{- if .Values.node.resources }}
          {{- with .Values.node.resources }}
          resources: {{ toYaml . | nindent 12 }}
          {{- end }}
          {{- else }}
          {{- with .Values.resources }}
          resources: {{ toYaml . | nindent 12 }}
          {{- end }}
          {{- end }}
        - name: liveness-probe
          image: {{ printf "%s:%s" .Values.sidecars.livenessProbeImage.repository .Values.sidecars.livenessProbeImage.tag }}
          args:
            - --csi-address=unix:/csi/csi.sock
          volumeMounts:
            - name: plugin-dir
              mountPath: C:\csi
          {{- if .Values.node.resources }}
          {{- with .Values.node.resources }}
          resources: {{ toYaml . | nindent 12 }}
          {{- end }}
          {{- else }}
          {{- with .Values.resources }}
          resources: {{ toYaml . | nindent 12 }}
          {{- end }}
          {{- end }}
      {{- if .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- range .Values.imagePullSecrets }}
        - name: {{ . }}
      {{- end }}
      {{- end }}
      volumes:
        - name: kubelet-dir
          hostPath:
            path: C:\var\lib\kubelet
            type: Directory
        - name: plugin-dir
          hostPath:
            path: C:\var\lib\kubelet\plugins\ebs.csi.aws.com
            type: DirectoryOrCreate
        - name: registration-dir
          hostPath:
            path: C:\var\lib\kubelet\plugins_registry
            type: Directory
        - name: csi-proxy-disk-pipe
          hostPath:
            path: \\.\pipe\csi-proxy-disk-v1beta2
            type: ""
        - name: csi-proxy-volume-pipe
          hostPath:
            path: \\.\pipe\csi-proxy-volume-v1beta2
            type: ""
        - name: csi-proxy-filesystem-pipe
          hostPath:
            path: \\.\pipe\csi-proxy-filesystem-v1beta1
            type: ""
