apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluent-bit-windows
  namespace: amazon-cloudwatch
  labels:
    k8s-app: fluent-bit
    version: v1
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      k8s-app: fluent-bit
  template:
    metadata:
      labels:
        k8s-app: fluent-bit
        version: v1
        kubernetes.io/cluster-service: "true"
    spec:
      securityContext:
        windowsOptions:
          hostProcess: true
          runAsUserName: "NT AUTHORITY\\System"
      hostNetwork: true
      nodeSelector:
        kubernetes.io/os: windows
      containers:
        - name: fluent-bit
          image: public.ecr.aws/aws-observability/aws-for-fluent-bit:windowsservercore-stable
          imagePullPolicy: Always
          command: ["powershell.exe", "-Command", "New-Item -ItemType Directory -Path C:\\var\\fluent-bit\\state -Force;", "%CONTAINER_SANDBOX_MOUNT_POINT%/fluent-bit/bin/fluent-bit.exe", "-e", "%CONTAINER_SANDBOX_MOUNT_POINT%/fluent-bit/kinesis.dll", "-e", "%CONTAINER_SANDBOX_MOUNT_POINT%/fluent-bit/firehose.dll", "-e", "%CONTAINER_SANDBOX_MOUNT_POINT%/fluent-bit/cloudwatch.dll", "-c", "%CONTAINER_SANDBOX_MOUNT_POINT%/fluent-bit/configuration/fluent-bit.conf"]
          env:
            - name: AWS_REGION
              valueFrom:
                configMapKeyRef:
                  name: "fluent-bit-cluster-info"
                  key: "logs.region"
            - name: CLUSTER_NAME
              valueFrom:
                configMapKeyRef:
                  name: "fluent-bit-cluster-info"
                  key: "cluster.name"
            - name: READ_FROM_HEAD
              valueFrom:
                configMapKeyRef:
                  name: "fluent-bit-cluster-info"
                  key: "read.head"
            - name: HOST_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: HOSTNAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: CI_VERSION
              value: "k8s/1.3.17"
          resources:
            limits:
              cpu: 500m
              memory: 600Mi
            requests:
              cpu: 500m
              memory: 600Mi
          volumeMounts:
            - name: fluent-bit-config
              mountPath: fluent-bit\configuration\
      volumes:
        - name: fluent-bit-config
          configMap:
            name: fluent-bit-windows-config
      terminationGracePeriodSeconds: 10
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccountName: cloudwatch-agent
