apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: loki-alloy
  namespace: loki
  labels:
    helm.sh/chart: alloy-1.5.2
    app.kubernetes.io/name: alloy
    app.kubernetes.io/instance: loki
    app.kubernetes.io/version: "v1.12.2"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: alloy
spec:
  minReadySeconds: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: alloy
      app.kubernetes.io/instance: loki
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: alloy
      labels:
        app.kubernetes.io/name: alloy
        app.kubernetes.io/instance: loki
    spec:
      serviceAccountName: loki-alloy
      containers:
        - name: alloy
          image: docker.io/grafana/alloy:v1.12.2
          imagePullPolicy: IfNotPresent
          args:
            - run
            - /etc/alloy/config.alloy
            - --storage.path=/tmp/alloy
            - --server.http.listen-addr=0.0.0.0:12345
            - --server.http.ui-path-prefix=/
            - --stability.level=generally-available
          env:
            - name: ALLOY_DEPLOY_MODE
              value: "helm"
            - name: HOSTNAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          ports:
            - containerPort: 12345
              name: http-metrics
          readinessProbe:
            httpGet:
              path: /-/ready
              port: 12345
              scheme: HTTP
            initialDelaySeconds: 10
            timeoutSeconds: 1
          volumeMounts:
            - name: config
              mountPath: /etc/alloy
        - name: config-reloader
          image: quay.io/prometheus-operator/prometheus-config-reloader:v0.81.0
          args:
            - --watched-dir=/etc/alloy
            - --reload-url=http://localhost:12345/-/reload
          volumeMounts:
            - name: config
              mountPath: /etc/alloy
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
      dnsPolicy: ClusterFirst
      volumes:
        - name: config
          configMap:
            name: loki-alloy
