Deploy the linkerd helm chart on Digital Ocean Kubernetes Service
TypeScriptTo deploy a Helm chart onto a Digital Ocean Kubernetes service using Pulumi, you will need to create a Kubernetes cluster on Digital Ocean, and then use the Helm package to deploy Linkerd onto that cluster.
Here's how you can achieve that in detail:
-
Setup Pulumi: Before running the program, make sure you have Pulumi installed and configured for use with your Digital Ocean token.
-
Create a Digital Ocean Kubernetes Cluster: Use the
digitalocean.KubernetesCluster
resource to create a new Kubernetes cluster in your Digital Ocean account. -
Deploy Linkerd Helm Chart: Once the Kubernetes cluster is up and running, the next step is to deploy the Linkerd Helm chart on it using the
kubernetes.helm.v3.Chart
resource from the Kubernetes provider.
Below is a Pulumi TypeScript program that accomplishes the creation of the Digital Ocean Kubernetes cluster and deploys the Linkerd Helm chart to that cluster:
import * as pulumi from "@pulumi/pulumi"; import * as digitalocean from "@pulumi/digitalocean"; import * as kubernetes from "@pulumi/kubernetes"; // Step 1: Provision a DigitalOcean Kubernetes Cluster const cluster = new digitalocean.KubernetesCluster("linkerd-cluster", { region: digitalocean.Regions.NYC1, version: "latest", // specify the Kubernetes version or use "latest" nodePool: { name: "worker-pool", size: digitalocean.DropletSlugs.DropletS2VCPU2GB, // specify the size of the Droplet nodeCount: 2, // specify the number of nodes in the node pool }, }); // Step 2: Install the Linkerd Helm Chart onto the cluster const linkerdChart = new kubernetes.helm.v3.Chart("linkerd", { chart: "linkerd2", version: "stable-2.9.4", // specify the version of the Linkerd chart fetchOpts: { repo: "https://helm.linkerd.io/stable", // Linkerd Helm repository }, }, { provider: new kubernetes.Provider("k8s-provider", { kubeconfig: cluster.kubeConfigs[0].rawConfig }) }); // Export the cluster's kubeconfig and the Linkerd dashboard service URL export const kubeconfig = cluster.kubeConfigs[0].rawConfig; export const linkerdDashboard = linkerdChart.getResourceProperty("v1/Service", "linkerd", "linkerd-web", "status").apply(status => { // Assuming LoadBalancer service type, get the external IP for the dashboard const ingress = status.loadBalancer.ingress[0]; return ingress.ip || ingress.hostname; });
Here's what each part of the program does:
-
DigitalOcean Kubernetes Cluster: The
digitalocean.KubernetesCluster
resource sets up the Kubernetes cluster in New York City region with the sizes-2vcpu-2gb
for your node pool which contains 2 nodes. You should choose your Droplet size and region based on your specific needs and budget. -
Kubernetes Provider: A Kubernetes provider instance is created with a
kubeconfig
obtained from the newly created Digital Ocean Kubernetes cluster. This provider will be used to interface with the cluster for deploying Helm charts. -
Linkerd Helm Chart: The
kubernetes.helm.v3.Chart
resource is used to deploy the Linkerd service mesh Helm chart to your cluster. It uses versionstable-2.9.4
of the chart from the official Linkerd Helm repository. -
Exporting Configuration: At the end, the kubeconfig of the created cluster is exported, so you can use it with
kubectl
or other Kubernetes tools to interact with your cluster. Additionally, the IP address or hostname for the Linkerd dashboard is exported, which once available, you can visit in a web browser to access the Linkerd dashboard.
After writing the above program into a
index.ts
file in a Pulumi project, you can create the resources defined by the program by runningpulumi up
in the command line from the same directory.Remember to monitor the output of
pulumi up
for the detail of resources being created and their status.Important Note: A Helm chart can have configurable values that you can override as needed. The Linkerd Helm chart, for example, allows for various configurations. The above program deploys Linkerd with the default configuration. Make sure to consult the Linkerd Helm chart documentation for additional configurations you may need.
-