# Install Datadog Agent on Kubernetes

Learn how to install the Datadog Agent for Kloudfuse, depending on your specific business scenario.

## Install a New Datadog Agent

Consider these installation scenarios:

- [Same VPC, Same Cluster](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#same-new)
- [Same VPC, Different Cluster](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#diff-k8-new)
- [Different VPC](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#diff-vpc-new)

### Kloudfuse Stack and Target in the Same VPC and Same Kubernetes Cluster

This is the default scenario.

1. Use the [dd-values-kfuse-customer.yaml file](https://docs.kloudfuse.com/platform/3.3.6/_attachments/dd-values-kfuse-customer.yaml) for the agent.
2. Add the datadog helm repo:
   
   ```console
   helm repo add datadog https://helm.datadoghq.com
   helm repo update
   ```

3. Install the datadog agent with updated values.
   
   As necessary, create a separate namespace for the agent.
   
   ```console
   kubectl create namespace kfuse-agent
   helm upgrade --install kfuse-agent -f dd-values-kfuse.yaml datadog/datadog -n kfuse-agent --version 3.65.0 (1)
   ```

|     |     |
| --- | --- |
| **1** | We use the<br>`dd-values-kfuse.yaml` file here; replace with the<br>filename relevant to your scenario. |

### Kloudfuse Stack and Target are in Same VPC but Different Kubernetes Cluster

1. Search for `_url` in the provided file.
   For each instance:
   
   1. Comment out the **Default Scenario**.
   2. Remove comment marks from **Scenario 1**.
   
2. To determine the necessary IP address values, follow these steps:
   
   1. Get ingress internal IP:
   
   ```console
   kubectl get svc -n kfuse | grep kfuse-ingress-nginx-controller-internal
   kfuse-ingress-nginx-controller-internal   LoadBalancer   10.53.250.80    10.53.232.3   80:32716/TCP,443:30767/TCP   125m
   ```
   
   2. Replace all settings with `_url` suffix.
   
      For example:
   
   ```console
   dd_url: http://10.53.250.80/ingester
   logs_dd_url: "10.53.250.80:80"
   ```

### Kloudfuse Stack and Target Hosted in Different VPCs

In this scenario, Kloudfuse appears as "customer.kloudfuse.io".

1. Search for `_url` in the provided file.
   For each instance:
   
   1. Comment out the **Default Scenario**.
   2. Remove comment marks from **Scenario 2**.
   
2. Replace "customer.kloudfuse.io" with your custom DNS name entry.
3. Replace all settings with `_url` suffix.
   
   For example:
   
   ```console
   dd_url: http://customer.kloudfuse.io/ingester
   logs_dd_url: "customer.kloudfuse.io:443"
   ```

## Install with an Existing Datadog Agent

Datadog Agent supports dual shipping. If you have an existing datadog agent, you can use it to send your data streams to the Kloudfuse platform.

### Prerequisites

When using an existing datadog agent and pointing to a Kloudfuse ingestion endpoint instead of Datadog HQ, make sure to:

- Use Datadog agent version 7.41 or higher.
- Validate the installation:
   
   1. Check that the chart version with helm list is 3.1.10 or higher:
   
   ```console
   helm list -n <namespace-where-agent-is-installed>
   ```
   
   2. Check the image version of the agent using `describe pod` on on the `dd-agent pod`:
   
   ```console
   kubectl describe pod -n <namespace-where-agent-is-installed> | grep Image
   Image:         gcr.io/datadoghq/agent:7.36.0
   ```

### Install

Consider these installation scenarios:

- [Same VPC, Same Cluster](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#same-existing)
- [Same VPC, Different Cluster](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#diff-k8-existing)
- [Different VPC](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#diff-vpc-existing)

### Kloudfuse Stack and Target in the Same VPC and Same Kubernetes Cluster

This is the default scenario.

1. Use the [dd-values-kfuse-customer.yaml file](https://docs.kloudfuse.com/platform/3.3.6/_attachments/dd-values-kfuse-customer.yaml) for the agent.
2. Run the [Install Command](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-kubernetes-install/#install-existing).

### Kloudfuse Stack and Target are in Same VPC but Different Kubernetes Cluster

### Kloudfuse Stack and Target Hosted in Different VPCs

In this scenario, Kloudfuse appears as "customer.kloudfuse.io".

### Install Command

1. Add the Datadog helm repo:
   
   ```console
   helm repo add datadog https://helm.datadoghq.com
   helm repo update
   ```

2. Install the Datadog agent with updated values.
   
   Create separate namespace for the agent you are installing.
   
   ```console
   kubectl create namespace kfuse-agent
   helm upgrade --install kfuse-agent -f dd-values-kfuse.yaml datadog/datadog -n kfuse-agent --version <version-number>
   ```

### Configure Helm

Add the following configurations into the datadog agent’s `helm` values, and remember to add change for **each stream**

1. Add this code under the `agents.customAgentConfig` key:
   
   ```yaml
   additional_endpoints:
        "http://<kfuse-ingress-external-ip>/ingester":
      - <api_key>
   use_v2_api:
   series: true
   logs_config:
   ...
   use_v2_api: false
   additional_endpoints:
       - api_key: <api_key>
         Host: <kfuse-ingress-external-ip>
         Port: 443
         use_compression: true
   apm_config:
   ...
   additional_endpoints:
       "https://kfuse-ingress-external-ip>/ingester":
          - <api_key>
   process_config:
   ...
   additional_endpoints:
       "https://kfuse-ingress-external-ip>":
          - <api_key>
   metadata_providers:
     - name: host
       interval: 300
   ```

2. Add this code under the `clusterAgent.datadog_cluster_yaml` key:
   
   ```yaml
   additional_endpoints:
        "http://<kfuse-ingress-external-ip>/ingester":
      - <api_key>
   use_v2_api:
   series: true
   process_config:
   ...
   additional_endpoints:
       "https://kfuse-ingress-external-ip>":
          - <api_key>
   orchestrator_explorer:
   ...
   additional_endpoints:
       "https://kfuse-ingress-external-ip>":
          - <api_key>
   ```
