---
# Source: splunk-otel-collector/templates/deployment-cluster-receiver.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: default-splunk-otel-collector-k8s-cluster-receiver
  labels:
    app.kubernetes.io/name: splunk-otel-collector
    helm.sh/chart: splunk-otel-collector-0.43.4
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/instance: default
    app.kubernetes.io/version: "0.43.0"
    app: splunk-otel-collector
    component: otel-k8s-cluster-receiver
    chart: splunk-otel-collector-0.43.4
    release: default
    heritage: Helm
    app.kubernetes.io/component: otel-k8s-cluster-receiver
spec:
  replicas: 2
  serviceName: default-splunk-otel-collector-k8s-cluster-receiver
  podManagementPolicy: Parallel
  selector:
    matchLabels:
      app: splunk-otel-collector
      component: otel-k8s-cluster-receiver
      release: default
  template:
    metadata:
      labels:
        app: splunk-otel-collector
        component: otel-k8s-cluster-receiver
        release: default
      annotations:
        checksum/config: c94bc28265b4d9d74d377b141745ed9910bffd6e9ffd3c3eaac56ea826ad95e1
    spec:
      serviceAccountName: default-splunk-otel-collector
      nodeSelector:
          kubernetes.io/os: linux
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: component
                operator: In
                values:
                - otel-k8s-cluster-receiver
            topologyKey: kubernetes.io/hostname
      initContainers:
        - name: cluster-receiver-node-discoverer
          image: public.ecr.aws/amazonlinux/amazonlinux:latest
          imagePullPolicy: IfNotPresent
          command: ["bash", "-c", "/splunk-scripts/init-eks-fargate-cluster-receiver.sh"]
          env:
            - name: K8S_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: K8S_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: init-eks-fargate-cluster-receiver-script
              mountPath: /splunk-scripts
            - name: messages
              mountPath: /splunk-messages
            - mountPath: /conf
              name: collector-configmap
      containers:
      - name: otel-collector
        command:
        - /otelcol
        - --config=/splunk-messages/config.yaml
        image: quay.io/signalfx/splunk-otel-collector:0.43.0
        imagePullPolicy: IfNotPresent
        env:
          - name: SPLUNK_MEMORY_TOTAL_MIB
            value: "500"
          - name: K8S_NODE_NAME
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
          - name: K8S_POD_IP
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: status.podIP
          - name: K8S_POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: K8S_POD_UID
            valueFrom:
              fieldRef:
                fieldPath: metadata.uid
          - name: K8S_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: SPLUNK_OBSERVABILITY_ACCESS_TOKEN
            valueFrom:
              secretKeyRef:
                name: splunk-otel-collector
                key: splunk_observability_access_token
        readinessProbe:
          httpGet:
            path: /
            port: 13133
        livenessProbe:
          httpGet:
            path: /
            port: 13133
        resources:
          limits:
            cpu: 200m
            memory: 500Mi
        volumeMounts:
        - mountPath: /conf
          name: collector-configmap
        - mountPath: /splunk-messages
          name: messages
      terminationGracePeriodSeconds: 600
      volumes:
      - name: collector-configmap
        configMap:
          name: default-splunk-otel-collector-otel-k8s-cluster-receiver
          items:
            - key: relay
              path: relay.yaml
      - name: init-eks-fargate-cluster-receiver-script
        configMap:
          name: default-splunk-otel-collector-cr-node-discoverer-script
          items:
            - key: script
              path: init-eks-fargate-cluster-receiver.sh
              mode: 0555
      - name: messages
        emptyDir: {}
