Deploy the shortlink-bff-web helm chart on Digital Ocean Kubernetes Service
TypeScriptTo deploy the
shortlink-bff-web
Helm chart on the Digital Ocean Kubernetes Service, you will first need to create a Kubernetes cluster on Digital Ocean using Pulumi. Once the cluster is up, you can then proceed with the deployment of the Helm chart onto this cluster.To get started with this, you'd go through the following steps:
- Define the Kubernetes cluster: Using the
digitalocean.KubernetesCluster
resource, you will define the cluster specifics such as region, node pool details, and Kubernetes version. - Deploy the Helm Chart: After the cluster is up, you'll use the
kubernetes.helm.sh/v3.Chart
resource to deploy theshortlink-bff-web
Helm chart onto your Digital Ocean Kubernetes cluster.
Here's a Pulumi program written in TypeScript that achieves this. This code assumes you have already set up Pulumi with your Digital Ocean token and have the necessary Pulumi packages installed.
import * as digitalocean from '@pulumi/digitalocean'; import * as pulumi from '@pulumi/pulumi'; import * as k8s from '@pulumi/kubernetes'; // Step 1: Create a DigitalOcean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster('do-cluster', { region: 'nyc1', // Change to your preferred region version: 'latest', // You can specify a specific version of Kubernetes here nodePool: { name: 'default', size: 's-1vcpu-2gb', // This is the smallest node size nodeCount: 2, // Number of nodes you want }, }); // Step 2: Deploy the 'shortlink-bff-web' Helm chart onto the created Kubernetes cluster const kubeConfig = cluster.kubeConfigs[0].rawConfig; const k8sProvider = new k8s.Provider('do-k8s', {kubeconfig: kubeConfig}); const chart = new k8s.helm.v3.Chart('shortlink-bff-web', { chart: 'shortlink-bff-web', // This should be the name of the chart you want to deploy. // You may need 'repo' property if this chart is in a custom Helm Chart repository. version: '1.0.0', // Adjust as needed for the chart version you wish to deploy namespace: 'default', // The namespace to deploy the Helm chart into values: { /* ... provide necessary values ... */ }, }, { provider: k8sProvider }); // Export the cluster's kubeconfig export const kubeconfig = kubeConfig;
In this program:
- The
digitalocean.KubernetesCluster
resource initializes a new cluster in thenyc1
region with two nodes (s-1vcpu-2gb
size). Feel free to change the size, count, or region according to your requirements. - The
kubeconfig
for the new cluster is extracted from the created cluster resource, which is necessary for the Kubernetes provider to communicate with the cluster. - The
k8s.Provider
resource is a Pulumi provider that uses thekubeconfig
to manage Kubernetes resources. - The
k8s.helm.v3.Chart
resource deploys theshortlink-bff-web
Helm chart onto the cluster. Replace the chart name, version, and other specifics according to the chart you want to deploy. You can also provide specific values to customize your deployment through thevalues
property. - Finally, the program exports the kubeconfig so that you can access the cluster with
kubectl
or other Kubernetes tooling.
Remember to replace
/* ... provide necessary values ... */
with the appropriate values for your Helm chart.To run this Pulumi program, you'd need to have Pulumi installed, alongside Node.js and the NPM package manager. Then, you initialize a new Pulumi project and add the required dependencies with NPM:
# Initialize a new Pulumi project pulumi new typescript # Install dependencies npm install @pulumi/digitalocean @pulumi/pulumi @pulumi/kubernetes
After configuring your Digital Ocean token (
pulumi config set digitalocean:token $TOKEN --secret
) and entering the deployment information, you can run the Pulumi CLI to deploy your infrastructure:# Preview the deployment pulumi up --yes
Upon successful execution, Pulumi will report the resources it created and any output values, such as the cluster's kubeconfig. You can now use this kubeconfig to interact with your Kubernetes cluster and verify that the Helm chart was deployed correctly.
- Define the Kubernetes cluster: Using the