Deploy the universal-chart helm chart on Digital Ocean Kubernetes Service
TypeScriptTo deploy the
universal-chart
Helm chart on a DigitalOcean Kubernetes (DOKS) cluster using Pulumi, we will perform several steps. Firstly, we will define the DOKS cluster itself. Then, we will configure the Kubernetes provider to interact with this DOKS cluster. Finally, we will create an instance of the Helm chart and deploy it on the cluster.In this program, we will use the
digitalocean
andkubernetes
Pulumi packages. Thedigitalocean.KubernetesCluster
resource type from thedigitalocean
package is used to create a new Kubernetes cluster in DigitalOcean. Once the cluster is provisioned, we will use thekubernetes
provider to interact with it and thekubernetes.helm.v3.Chart
resource type to deploy the Helm chart.Below is a detailed Pulumi program written in TypeScript that accomplishes this deployment:
import * as digitalocean from "@pulumi/digitalocean"; import * as kubernetes from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // 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: "1.21.5-do.0", // Set up the node pool configuration nodePool: { name: "default", size: digitalocean.DropletSlugs.DropletS2VCPU2GB, nodeCount: 2, // Specify the number of nodes in the pool }, }); // Once the cluster is created, we can use the cluster's kubeconfig to interact with it // through the Kubernetes provider. const k8sProvider = new kubernetes.Provider("k8s-provider", { kubeconfig: cluster.kubeConfigs[0].rawConfig, }); // Deploying the universal-chart Helm chart to the DigitalOcean cluster. const helmChart = new kubernetes.helm.v3.Chart("universal-chart", { chart: "universal-chart", // Replace with the actual repository URL or name where the chart is hosted // If your chart is in a publicly hosted repository like Bitnami or stable, you can use the repository name // If it is in a private repository, you need to provide the full URL fetchOpts: { repo: "https://charts.example.com/", // Place the URL of the chart repository here }, // Pass the necessary values to configure the Helm chart values: { // Example configuration: adjust these values based on the chart's requirements service: { type: "ClusterIP", }, }, }, {provider: k8sProvider}); // Specify the provider to interact with the cluster // Export the cluster's name and Kubeconfig export const clusterName = cluster.name; export const kubeconfig = cluster.kubeConfigs[0].rawConfig; // To access the Kubernetes cluster after your Pulumi program runs, you can use this // exported kubeconfig with `kubectl` or any Kubernetes management tool.
This program does the following:
- Configure DigitalOcean Kubernetes Cluster: We first create a Kubernetes cluster in the desired region and with the specified Kubernetes version using the
digitalocean.KubernetesCluster
resource. - Set up Kubernetes Provider: A Pulumi Kubernetes provider is defined to interact with the created DOKS cluster, using the kubeconfig obtained from the DigitalOcean cluster.
- Deploy Helm Chart: The
universal-chart
helm chart is then deployed to the cluster through the Helm chart resource. ThefetchOpts.repo
should be replaced with the actual repository URL where your Helm chart is hosted. Additionally, you are required to adjust thevalues
section to match the requirements for your specific chart. - Export Configuration: Finally, the Kubernetes cluster name and the raw kubeconfig are exported. You can use these exported details to interact with the cluster using
kubectl
or any other Kubernetes tooling.
Keep in mind:
- Replace
https://charts.example.com/
with the actual repository of your Helm chart. - Customize the
values
object to suit the configuration of youruniversal-chart
. The values should be defined based on what the chart expects and requires. - For further details about the Helm chart resource, you can visit the Pulumi documentation for Helm charts.
- Ensure that you have the Pulumi CLI installed and configured with access to your DigitalOcean account.
After you have this program ready, you can run
pulumi up
in your terminal to deploy the DOKS cluster and the Helm chart.- Configure DigitalOcean Kubernetes Cluster: We first create a Kubernetes cluster in the desired region and with the specified Kubernetes version using the