Deploy the workflow-service helm chart on Kubernetes
TypeScriptTo deploy a Helm chart on Kubernetes using Pulumi, we need to do the following:
- Set up the Kubernetes provider to interact with your Kubernetes cluster.
- Use the
Chart
resource from the@pulumi/kubernetes
package to deploy the Helm chart.
First, make sure you have access to your Kubernetes cluster and the
kubeconfig
for the cluster is correctly configured on your system where you're running Pulumi. This is important because Pulumi uses thekubeconfig
file to communicate with your Kubernetes cluster.Next, we'll write a Pulumi program in TypeScript that deploys the
workflow-service
Helm chart. This example assumes that the Helm chart is available in a Helm repository that Pulumi can access.Here is a detailed explanation with the Pulumi TypeScript program:
import * as k8s from "@pulumi/kubernetes"; // Create an instance of the Kubernetes Chart class to deploy the workflow-service chart. const workflowServiceChart = new k8s.helm.v3.Chart("workflow-service", { // Specify the Helm chart repository and the chart name. // This example assumes that the chart is available in a repository which Pulumi should be configured to use. // If the repository is not already added to the Helm local configuration, you might need to add it using `helm repo add` command or provide an absolute `repo` URL here. chart: "workflow-service", // Specify the namespace where the chart should be deployed. // If the namespace does not exist, you should create it beforehand or set `resourcePrefix` to `true`. namespace: "default", // You can pass values to the chart to configure it; these values would be specific to the workflow-service chart. // For example, setting a dummy 'replicas' value would look like the `values` structure below. // Replace this with actual configuration parameters for the workflow-service chart. values: { replicas: 1, }, // If you need a specific version of the Helm chart, provide the `version` property. // version: "1.2.3", // If your chart requires custom fetching options, specify them in the `fetchOpts`. // fetchOpts: { // ... // }, }); // Export the Chart's status to provide output that can be used to track the deployment's success or failure. export const chartStatus = workflowServiceChart.status;
This Pulumi program does the following:
- Imports the Kubernetes package from Pulumi which will be used to interact with the Kubernetes API.
- Creates a new Helm chart instance named
workflow-service
using theChart
class from the@pulumi/kubernetes
package. - Specifies the name of the Helm chart and the namespace to deploy it to. Replace
"default"
with the actual namespace you'd like to deploy to if different. - Optionally provides custom
values
to the Helm chart if you want to override the chart's default settings. - Exports the status of the Helm chart, which can be used to monitor the deployment progress.
Before you can run the program, make sure you have Pulumi and Kubernetes set up:
- Install the Pulumi CLI from the official website.
- Set up Kubernetes and ensure that you can connect to your Kubernetes cluster using
kubectl
. - With Pulumi CLI installed, authenticate to the Pulumi platform.
- Create a Pulumi stack using
pulumi stack init
.
To run the program, execute the following commands:
pulumi up
This command checks your code for errors, displays a preview of the resources to be created, and awaits your approval before provisioning the resources.
After approving, Pulumi will deploy the Helm chart to your Kubernetes cluster, and you'll be able to see the deployment's progress and get the chart's status outputted from the Pulumi program.