Helm chart v2.7.0+ または Datadog Operator v0.7.0+ を使用して Datadog Agent をデプロイした場合、Cluster Agent はデフォルトで有効化されます。

The Cluster Agent is enabled by default since Datadog Operator v1.0.0. The Operator creates the necessary RBACs, deploys the Cluster Agent, and modifies the Agent DaemonSet configuration.

This also automatically generates a random token in a Secret shared by both the Cluster Agent and the Datadog Agent to secure communication. You can manually specify this token by setting the global.clusterAgentToken field. You can alternatively set this by referencing the name of an existing Secret and the data key containing this token.

apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: datadog
spec:
  global:
    credentials:
      apiKey: <DATADOG_API_KEY>
    clusterAgentTokenSecret:
      secretName: <SECRET_NAME>
      keyName: <KEY_NAME>

When set manually, this token must be 32 alphanumeric characters.

Helm チャート v2.7.0 以降、Cluster Agent はデフォルトで有効になっています。

古いバージョンで有効にする場合、または clusterAgent キーを上書きするカスタム datadog-values.yaml を使用する場合、以下の Cluster Agent コンフィギュレーションで datadog-values.yaml ファイルを更新します。

clusterAgent:
  # clusterAgent.enabled -- これを false に設定すると、Datadog Cluster Agent が無効になります
  enabled: true

次に、Datadog Helm チャートをアップグレードします。

これにより、Cluster Agent と Datadog Agent に必要な RBAC ファイルが自動的に更新されます。両方の Agent が同じ API キーを使用します。

This also automatically generates a random token in a Secret shared by both the Cluster Agent and the Datadog Agent to secure communication. You can manually specify this token using the clusterAgent.token configuration. You can alternatively set this by referencing the name of an existing Secret containing a token value through the clusterAgent.tokenExistingSecret configuration.

When set manually, this token must be 32 alphanumeric characters.

DaemonSet を使用して Datadog Cluster Agent をセットアップするには

  1. Cluster Agent RBAC 権限を構成します
  2. Cluster Agent と Agent 間の通信を確立します
  3. Cluster Agent とそのサービスを作成します
  4. Configure the node Agent to communicate with the Cluster Agent.

Cluster Agent RBAC 権限の構成

Datadog Cluster Agent を実行するには、適切な RBAC が必要です。

  1. Datadog Cluster Agent RBAC フォルダーにあるマニフェストを確認します。: Cluster Agentを使用する場合、Kubernetes API サーバーと通信できるのは Cluster Agent だけで、Node Agent ではないことにご注意ください。

  2. Cluster Agent に対する RBAC アクセス許可を構成するには、以下のマニフェストを適用します。(Node Agent デーモンセットを設定する際に、すでに行っている可能性があります。)

kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/cluster-agent/rbac.yaml"
kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/cluster-agent/cluster-agent-rbac.yaml"

これにより、Cluster Agent に適切な ServiceAccountClusterRoleClusterRoleBinding が作成され、ノード Agent の ClusterRole が更新されます。

Azure Kubernetes Service (AKS) の場合、追加のアクセス許可が必要になる可能性もあります。DCA のため AKS で RBAC に関する「よくあるご質問」を参照してください。

Cluster Agent - Agent 間通信のセキュリティ保護

Datadog Agent と Cluster Agent は、通信を保護するためにトークンを必要とします。このトークンは、Datadog Agent と Cluster Agent の両方が環境変数 DD_CLUSTER_AGENT_AUTH_TOKEN で参照できる Secret に保存することをお勧めします。これは、一貫性を維持し、トークンが PodSpec で読み取り可能になることを防ぐのに役立ちます。

このトークンを作成するには、この 1 行のコマンドを実行して、token が設定された datadog-cluster-agent という名前の Secret を生成します。<TOKEN> を 32 文字の英数字に置き換えます。

kubectl create secret generic datadog-cluster-agent --from-literal=token='<TOKEN>' --namespace="default"

: これにより、デフォルトネームスペースで Secret が作成されます。カスタムネームスペースを使用している場合、実行前にコマンドのネームスペースパラメーターを更新します。

Cluster Agent に提供されているデフォルトの cluster-agent-deployment.yaml は、環境変数のコンフィギュレーションでこの Secret を参照するように既に構成されています。

- name: DD_CLUSTER_AGENT_AUTH_TOKEN
  valueFrom:
    secretKeyRef:
      name: datadog-cluster-agent
      key: token

この環境変数は、Datadog Agent の構成で (同じセットアップを使用して) 構成する必要があります。

Cluster Agent とそのサービスの作成

  1. 以下のマニフェストをダウンロードします。

  2. secret-api-key.yaml マニフェストで、PUT_YOUR_BASE64_ENCODED_API_KEY_HERE を base64 でエンコードされた Datadog API キーに置き換えます。API キーの base64 バージョンを取得するには、次のコマンドを実行します。

    echo -n '<Your API key>' | base64
    
  3. secrets-application-key.yaml マニフェストで、PUT_YOUR_BASE64_ENCODED_APP_KEY_HERE を base64 でエンコードされた Datadog アプリケーションキーに置き換えます。

  4. デフォルトでは、cluster-agent-deployment.yaml マニフェストは、以前に Secret datadog-cluster-agent で作成されたトークンを参照します。このトークンを代替の方法で保存する場合は、それに応じて DD_CLUSTER_AGENT_AUTH_TOKEN 環境変数を構成します。

  5. Cluster Agent Deployment が使用するために、これらのリソースをデプロイします。

    kubectl apply -f agent-services.yaml
    kubectl apply -f secret-api-key.yaml
    kubectl apply -f secret-application-key.yaml
    kubectl apply -f install_info-configmap.yaml
    
  6. 最後に、Datadog Cluster Agent をデプロイします。

    kubectl apply -f cluster-agent-deployment.yaml
    

: Datadog Cluster Agent で、環境変数 DD_SITE を Datadog サイトに設定します: 。デフォルトは US サイト datadoghq.com です。

検証

この時点で、次のような状態になっているはずです。

kubectl get deploy

NAME                    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
datadog-cluster-agent   1         1         1            1           1d

kubectl get secret

NAME                    TYPE                                  DATA      AGE
datadog-cluster-agent   Opaque                                1         1d

kubectl get pods -l app=datadog-cluster-agent

datadog-cluster-agent-8568545574-x9tc9   1/1       Running   0          2h

kubectl get service -l app=datadog-cluster-agent

NAME                    TYPE           CLUSTER-IP       EXTERNAL-IP        PORT(S)          AGE
datadog-cluster-agent   ClusterIP      10.100.202.234   none               5005/TCP         1d

: すでに Datadog Agent を実行している場合は、Cluster Agent の実行を開始する前に、Agent の rbac.yaml マニフェストを適用する必要がある場合があります。

Datadog Agent の通信の構成

Datadog Cluster Agent と通信するために、Datadog Agent の構成を変更します。

既存の DaemonSet マニフェストファイルで、環境変数 DD_CLUSTER_AGENT_ENABLEDtrue に設定します。次に、Secure Cluster-Agent-to-Agent Communication で使用されているのと同じ構文を使用して DD_CLUSTER_AGENT_AUTH_TOKEN を設定します。

- name: DD_CLUSTER_AGENT_ENABLED
  value: "true"
- name: DD_CLUSTER_AGENT_AUTH_TOKEN
  valueFrom:
    secretKeyRef:
      name: datadog-cluster-agent
      key: token

これらの構成で DaemonSet を再デプロイすると、Datadog Agent は Cluster Agent と通信できるようになります。完全な例については、提供されている Cluster Agent daemonset.yaml マニフェストを参照することができます。

検証

次のコマンドを実行して、Datadog Agent ポッドと Cluster Agent ポッドが実行されていることを確認できます。

kubectl get pods | grep agent

次のようになるはずです。

datadog-agent-4k9cd                      1/1       Running   0          2h
datadog-agent-4v884                      1/1       Running   0          2h
datadog-agent-9d5bl                      1/1       Running   0          2h
datadog-agent-dtlkg                      1/1       Running   0          2h
datadog-agent-jllww                      1/1       Running   0          2h
datadog-agent-rdgwz                      1/1       Running   0          2h
datadog-agent-x5wk5                      1/1       Running   0          2h
[...]
datadog-cluster-agent-8568545574-x9tc9   1/1       Running   0          2h

さらに、Agent ステータス出力を使用して、Datadog Agent が Cluster Agent に正常に接続したことを確認できます。

kubectl exec -it <AGENT_POD_NAME> agent status
[...]
=====================
Datadog Cluster Agent
=====================

  - Datadog Cluster Agent endpoint detected: https://10.104.246.194:5005
  Successfully connected to the Datadog Cluster Agent.
  - Running: 1.11.0+commit.4eadd95

Datadog アカウントに Kubernetes イベントが流れ込み始め、Agent によって収集された関連メトリクスに、それぞれに対応するクラスターレベルのメタデータがタグ付けされます。

Windows コンテナ

Datadog Cluster Agent は、Linux ノードにのみデプロイ可能です。

Windows コンテナを監視するには、混在クラスターに 2 つの Helm チャートをインストールします。最初の Helm チャートは、Linux ノード用に Datadog Cluster Agent と Agent DaemonSet をデプロイします (targetSystem: linux を使用)。2 つ目の Helm チャート (targetSystem: windows を使用) は、Windows ノードにのみ Agent をデプロイし、最初の Helm チャートの一部としてデプロイされた既存の Cluster Agent に接続します。

Use the following datadog-values.yaml file to configure communication between Agents deployed on Windows nodes and the Cluster Agent.

targetSystem: windows
existingClusterAgent:
  join: true
  serviceName: "<EXISTING_DCA_SECRET_NAME>" # Datadog Helm の最初のチャートから
  tokenSecretName: "<EXISTING_DCA_SERVICE_NAME>" # Datadog Helm の最初のチャートから

# datadogMetrics は最初のチャートで既にデプロイされているはずなので、デプロイを無効にします。
datadog-crds:
  crds:
    datadogMetrics: false
# kube-state-metrics のデプロイメントを無効にします
datadog:
  kubeStateMetricsEnabled: false

詳しくは、Windows コンテナの問題のトラブルシューティングをご覧ください。

AWS の管理型サービスを監視

To monitor an AWS managed service like Amazon Managed Streaming for Apache Kafka (MSK), ElastiCache, or Relational Database Service (RDS), set clusterChecksRunner in your Helm chart to create a Pod with an IAM role assigned through serviceAccountAnnotation. Then, set the integration configurations under clusterAgent.confd.

datadog-values.yaml

clusterChecksRunner:
  enabled: true
  rbac:
    # clusterChecksRunner.rbac.create -- true の場合は RBAC リソースを作成・使用
    create: true
    dedicated: true
    serviceAccountAnnotations:
      eks.amazonaws.com/role-arn: arn:aws:iam::***************:role/ROLE-NAME-WITH-MSK-READONLY-POLICY
clusterAgent:
  confd:
    amazon_msk.yaml: |-
      cluster_check: true
      instances:
        - cluster_arn: arn:aws:kafka:us-west-2:*************:cluster/gen-kafka/*******-8e12-4fde-a5ce-******-3
          region_name: us-west-2      

その他の参考資料

PREVIEWING: evan.li/clarify-agentless