1. Deploy the logdna-agent helm chart on Kubernetes


    To deploy the LogDNA agent on a Kubernetes cluster using Pulumi and Helm, we'll use the kubernetes.helm.v3.Chart resource from Pulumi's Kubernetes provider. This resource lets us deploy a Helm chart into a Kubernetes cluster.

    Here's how the process will work:

    1. First, we need to have a Kubernetes cluster. If you don't already have one, you would first need to create it using Pulumi with a provider like eks.Cluster, azure-native.kubernetes.Cluster, or gcp.container.Cluster. In this example, we'll assume you already have a cluster set up and that your ~/.kube/config is pointing to it.

    2. Next, we'll define the Helm chart resource using the kubernetes.helm.v3.Chart class. We specify the name of the chart, logdna-agent, and any configuration values that the chart accepts.

    3. Once we complete the Pulumi program, we can deploy it using the Pulumi CLI with pulumi up.

    Now let's look at the TypeScript program to accomplish this:

    import * as k8s from '@pulumi/kubernetes'; // Create a Chart resource that deploys LogDNA agent, assuming Helm chart is available in a public repository const logdnaChart = new k8s.helm.v3.Chart("logdna-agent", { chart: "logdna-agent", version: "2.x.x", // specify the appropriate chart version fetchOpts: { repo: "https://assets.logdna.com/charts", // this is the Helm repository for LogDNA }, values: { // Use values to set chart configuration like setting up LogDNA ingestion key. // Replace `YOUR_INGESTION_KEY` with your actual LogDNA ingestion key. logdna: { key: "YOUR_INGESTION_KEY", }, }, }); // Export the base URL for the LogDNA service export const logdnaBaseUrl = logdnaChart.getResourceProperty("v1/Service", "logdna-agent", "status", "loadBalancer", "ingress", 0, "hostname");

    Before you run the pulumi up command, make sure you have installed Pulumi CLI and logged in to your account. Additionally, you must have kubectl installed and configured to connect to your Kubernetes cluster.

    In the code above, we're deploying the LogDNA agent Helm chart to our Kubernetes cluster. We specify the chart name (logdna-agent), the chart version (replace 2.x.x with the actual version number you wish to deploy), and the repository URL where the chart can be found. In the values section, you would replace YOUR_INGESTION_KEY with the actual ingestion key provided by LogDNA.

    After deployment, we export the LogDNA base URL. Depending on the LogDNA Helm chart's service configuration, this URL might be used to access LogDNA or interact with it in some way.

    For more granular details on the arguments and properties being used, you can always check out the Pulumi documentation for Helm charts.

    Remember, Helm charts can have a variety of configurable values, and you should refer to the specific Helm chart documentation for LogDNA for the full list of options at LogDNA's Helm Chart repository. Adjust the values field in the code to match your configuration needs.