Deploy the worker helm chart on Kubernetes
TypeScriptTo deploy a Helm chart on Kubernetes using Pulumi, you need to have a Kubernetes cluster set up and configured with
kubectl
. Once you have your cluster ready, you can use Pulumi to deploy Helm charts to it.The following program will demonstrate how to deploy the "worker" Helm chart to a Kubernetes cluster. We will be using the
kubernetes.helm.v3.Chart
resource from the Pulumi Kubernetes provider. This resource allows you to deploy a Helm chart from a repository or a local path.Here's a step-by-step explanation of what the program does:
- Import the necessary packages.
- Create a new instance of the
kubernetes.helm.v3.Chart
resource. - Specify the name of the Helm chart to deploy ("worker" in this case).
- Optionally, you can provide custom values to the Helm chart by setting the
values
argument. - The process will deploy the Helm chart to the Kubernetes cluster in the specified namespace.
Here's the program that accomplishes this:
import * as pulumi from "@pulumi/pulumi"; import * as kubernetes from "@pulumi/kubernetes"; // Create an instance of the Helm chart to be deployed. // Replace `CHART-REPO-URL` with the URL of the Helm chart repository // and `CHART-VERSION` with the version of the chart you wish to deploy. const workerChart = new kubernetes.helm.v3.Chart("worker-chart", { // The repository where your chart can be found. This can be a Helm repository URL or a Git repository. repo: "CHART-REPO-URL", // The name of the chart in the repository. chart: "worker", // The version of the chart to deploy. Remove this line if you want to use the latest version. version: "CHART-VERSION", // Optional: If you have custom values you want to specify for your Helm chart, do so here. // values: { key: "value" }, // Specify the namespace where the chart should be deployed. // If you don't specify one, it will be deployed in the "default" namespace. namespace: "default", }); // When the program is run, this will output the resources that were created. export const chartResources = workerChart.resources;
Please replace
CHART-REPO-URL
with the actual URL of the Helm chart repository you are using andCHART-VERSION
with the specific version of the chart you would like to deploy, if you have any preference. If you want to deploy the latest version of the chart, you can omit theversion
field.The
values
attribute is where you can pass in any custom values to override default settings in the Helm chart. It is equivalent to using the-f values.yaml
or--set key=value
flags with thehelm install
command.This Pulumi program will deploy the Helm chart to your Kubernetes cluster in the specified namespace. Once you run this program with Pulumi, it will handle the communication with your Kubernetes cluster to deploy the chart.
Remember to have your Kubernetes context set correctly for Pulumi to be able to interact with your cluster. You also need to install the Pulumi CLI and the necessary plugins for this program to work.