---
# This file has been generated by `helm template datadog-agent datadog/datadog` from datadog/templates/cluster-agent-deployment.yaml. Please re-run `generate.sh` rather than modifying this file manually.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: datadog-cluster-agent
  namespace: default
  labels: {}
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  selector:
    matchLabels:
      app: datadog-cluster-agent
  template:
    metadata:
      labels:
        app.kubernetes.io/name: "datadog"
        app.kubernetes.io/instance: "datadog"
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: cluster-agent
        app: datadog-cluster-agent
      name: datadog-cluster-agent
      annotations: {}
    spec:
      serviceAccountName: datadog-cluster-agent
      containers:
        - name: cluster-agent
          image: "gcr.io/datadoghq/cluster-agent:1.18.0"
          imagePullPolicy: IfNotPresent
          resources: {}
          ports:
            - containerPort: 5005
              name: agentport
              protocol: TCP
            - containerPort: 5000
              name: agentmetrics
              protocol: TCP
            - containerPort: 8443
              name: metricsapi
              protocol: TCP
          env:
            - name: DD_HEALTH_PORT
              value: "5556"
            - name: DD_API_KEY
              valueFrom:
                secretKeyRef:
                  name: "datadog"
                  key: api-key
                  optional: true
            - name: DD_APP_KEY
              valueFrom:
                secretKeyRef:
                  name: "datadog-appkey"
                  key: app-key
            - name: DD_EXTERNAL_METRICS_PROVIDER_ENABLED
              value: "true"
            - name: DD_EXTERNAL_METRICS_PROVIDER_PORT
              value: "8443"
            - name: DD_EXTERNAL_METRICS_PROVIDER_WPA_CONTROLLER
              value: "false"
            - name: DD_EXTERNAL_METRICS_PROVIDER_USE_DATADOGMETRIC_CRD
              value: "true"
            - name: DD_EXTERNAL_METRICS_AGGREGATOR
              value: "avg"
            - name: DD_CLUSTER_CHECKS_ENABLED
              value: "true"
            - name: DD_EXTRA_CONFIG_PROVIDERS
              value: "kube_endpoints kube_services"
            - name: DD_EXTRA_LISTENERS
              value: "kube_endpoints kube_services"
            - name: DD_LOG_LEVEL
              value: "INFO"
            - name: DD_LEADER_ELECTION
              value: "true"
            - name: DD_COLLECT_KUBERNETES_EVENTS
              value: "true"
            - name: DD_CLUSTER_AGENT_KUBERNETES_SERVICE_NAME
              value: datadog-cluster-agent
            - name: DD_CLUSTER_AGENT_AUTH_TOKEN
              valueFrom:
                secretKeyRef:
                  name: datadog-cluster-agent
                  key: token
            - name: DD_KUBE_RESOURCES_NAMESPACE
              value: default
            - name: DD_ORCHESTRATOR_EXPLORER_ENABLED
              value: "true"
            - name: DD_ORCHESTRATOR_EXPLORER_CONTAINER_SCRUBBING_ENABLED
              value: "true"
          livenessProbe:
            failureThreshold: 6
            httpGet:
              path: /live
              port: 5556
              scheme: HTTP
            initialDelaySeconds: 15
            periodSeconds: 15
            successThreshold: 1
            timeoutSeconds: 5
          readinessProbe:
            failureThreshold: 6
            httpGet:
              path: /ready
              port: 5556
              scheme: HTTP
            initialDelaySeconds: 15
            periodSeconds: 15
            successThreshold: 1
            timeoutSeconds: 5
          volumeMounts:
            - name: installinfo
              subPath: install_info
              mountPath: /etc/datadog-agent/install_info
              readOnly: true
      volumes:
        - name: installinfo
          configMap:
            name: datadog-installinfo
      affinity:
        # Prefer scheduling the cluster agents on different nodes
        # to guarantee that the standby instance can immediately take the lead from a leader running of a faulty node.
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 50
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app: datadog-cluster-agent
                topologyKey: kubernetes.io/hostname
      nodeSelector:
        kubernetes.io/os: linux
