1. Deploy the linkerd helm chart on Kubernetes

    TypeScript

    Deploying a Helm chart on Kubernetes with Pulumi is a process that involves setting up the Kubernetes provider, then using the Helm chart component to deploy your chosen chart—in this case, Linkerd, which is a service mesh for Kubernetes.

    Below is a Pulumi program in TypeScript that deploys the Linkerd Helm chart on a Kubernetes cluster. It assumes that you have a Kubernetes cluster running and that you've configured kubectl to connect to it. Also, make sure your Pulumi CLI is installed and configured for use.

    The Pulumi Program Explained

    First, you import the necessary packages for the Pulumi Kubernetes provider and the Helm chart resource.

    Using the helm.v3.Chart resource, you are able to specify the details for deploying the Linkerd chart. You should specify the chart name, optionally the version, the fetchOpts which can include details such as the repo where the helm chart is hosted, any values you wish to pass to the Helm chart to customize it, and finally the namespace where you want to deploy the Linkerd service mesh.

    If the Kubernetes cluster is not managed by Pulumi, you don't need to explicitly create a provider instance—normally Pulumi will automatically use the currently active Kubernetes context as provided by your kubeconfig file.

    The Program

    import * as kubernetes from "@pulumi/kubernetes"; // Create a Kubernetes Namespace const linkerdNamespace = new kubernetes.core.v1.Namespace("linkerd-namespace", { metadata: { name: "linkerd", }, }); // Deploy Linkerd Helm Chart const linkerdChart = new kubernetes.helm.v3.Chart("linkerd-chart", { chart: "linkerd2", version: "2.11.1", // Use the desired version of Linkerd fetchOpts: { repo: "https://helm.linkerd.io/stable", }, namespace: linkerdNamespace.metadata.name, // If you have custom values, you can specify them using `values` // values: { // identity: { // issuer: { // tls: { crtExpiry: "2025-01-01T01:02:03Z" } // } // } // }, }); // Export the Linkerd web URL export const linkerdWebUrl = linkerdChart.getResourceProperty("v1/Service", "linkerd-web", "status") .apply(status => `http://${status.loadBalancer.ingress[0].ip}`);

    This program starts by importing the Pulumi Kubernetes package. Then, it creates a namespace for Linkerd to keep it separated from other applications running in your cluster. Next, it deploys the Linkerd Helm chart using the information provided, fetching it from the official Linkerd Helm repository.

    Running the Program

    Save this code in a file named index.ts. To run the program, execute pulumi up in the command line in the same directory as the file is located. This will prompt Pulumi to perform an update, showing you a preview of the actions that will be taken. If you're satisfied with the plan, proceed with the update. Once the update is completed, if Linkerd is exposed via a LoadBalancer service, the external IP of the linkerd-web service is exported.

    Note: Make sure you have Pulumi installed and configured alongside kubectl for the Kubernetes cluster you want to deploy to.

    After deployment, you can manage Linkerd using the linkerd CLI or the Kubernetes dashboard as per usual with any Linkerd installation.