1. Deploy the datadog-apm helm chart on Digital Ocean Kubernetes Service


    To deploy the Datadog APM Agent using a Helm chart on a DigitalOcean managed Kubernetes cluster using Pulumi, you'll need to follow these steps:

    1. Set up a DigitalOcean Kubernetes Cluster.
    2. Deploy the Datadog APM agent using a Helm chart to the cluster.

    Pulumi provides the necessary resources to create a Kubernetes cluster on DigitalOcean through the digitalocean.KubernetesCluster resource. Once the cluster is set up, you can deploy Helm charts to it using the kubernetes.helm.v3.Chart from the Kubernetes provider package.

    Here's a Pulumi program written in TypeScript that you can use to deploy a DigitalOcean Kubernetes cluster and then install the Datadog APM agent using Helm.

    This example assumes that you have already set up Pulumi with appropriate access to DigitalOcean and have the necessary credentials configured.

    import * as digitalocean from '@pulumi/digitalocean'; import * as k8s from '@pulumi/kubernetes'; // Create a DigitalOcean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster("do-cluster", { // Specify the region for the cluster region: digitalocean.Regions.NYC1, // Define the version of Kubernetes to use version: "latest", // Define the node pool specification nodePool: { name: "default", size: digitalocean.DropletSlugs.DropletS2VCPU2GB, // Determines the size of each node nodeCount: 2, // Number of nodes in the node pool }, }); // Create a Kubernetes provider instance using the kubeconfig from the newly created DigitalOcean cluster const provider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeConfigs[0].rawConfig, }); // Deploy the Datadog APM agent using the Datadog Helm chart const datadogChart = new k8s.helm.v3.Chart("datadog-apm", { chart: "datadog", // Name of the Helm chart version: "2.27.11", // Version of the Datadog Helm chart to deploy fetchOpts: { repo: "https://helm.datadoghq.com", // Datadog's Helm chart repository }, values: { datadog: { apiKey: "<YOUR_DATADOG_API_KEY>", // Use your Datadog API key apm: { enabled: true, // Enable APM }, }, }, }, { provider }); // Make sure to use the provider that refers to the DigitalOcean Kubernetes cluster // Export the cluster's kubeconfig and endpoint export const kubeconfig = cluster.kubeConfigs[0].rawConfig; export const clusterEndpoint = cluster.endpoint;

    Before running this program, replace <YOUR_DATADOG_API_KEY> with your actual Datadog API key.

    In the code above, we first declare our DigitalOcean Kubernetes cluster with a specific name, region, Kubernetes version, and node pool specification. The digitalocean.KubernetesCluster resource is responsible for creating and managing the lifecycle of the cluster.

    Next, we create a Pulumi Kubernetes provider that uses the cluster's kubeconfig so that Pulumi can communicate with our new DigitalOcean Kubernetes cluster. This step is essential as it tells Pulumi where to deploy resources.

    Then we use the kubernetes.helm.v3.Chart resource to deploy the Datadog APM agent. We specify datadog as the Helm chart name, set a version (this can be updated to the latest supported version), and provide the Datadog Helm repository URL where the chart can be fetched from. The values field allows us to configure the Helm chart with our settings, such as providing our Datadog API key and enabling APM.

    Finally, we export the kubeconfig and cluster endpoint. These exported values can be used to interact with the cluster outside of Pulumi, such as using kubectl to manage Kubernetes resources directly.

    To run this Pulumi program, save the code in a file called index.ts, and then execute the following commands:

    pulumi up

    This command will initiate the deployment. Pulumi will display a preview of the resources being created and prompt you for confirmation before proceeding. After reviewing the changes, approve them to let Pulumi apply the configuration and create the DigitalOcean Kubernetes cluster and install the Datadog APM agent.

    Once the deployment is complete, you can use the exported kubeconfig to interact with your Kubernetes cluster using kubectl, and the Datadog APM agent should be active and running on your cluster, reporting metrics to your Datadog account.