1. Deploy the trouw-service helm chart on Rancher


    Deploying a Helm chart using Pulumi involves several steps: setting up the Pulumi environment, creating a Kubernetes stack, installing and configuring providers, and finally deploying the Helm chart. Below is a detailed guide that explains how to deploy a Helm chart on Rancher using Pulumi with TypeScript.


    Before you begin, ensure the following prerequisites are met:

    • You have access to a Rancher-managed Kubernetes cluster with the necessary permissions to deploy services.
    • You have installed Pulumi CLI and configured it to communicate with your Kubernetes cluster. If you haven't done this yet, you can follow the Pulumi installation guide.
    • You have installed Node.js and npm, which is required to run the Pulumi program written in TypeScript.
    • You have authenticated with Rancher and have access to the kubeconfig file for your cluster.

    Setting Up the Pulumi Program

    A Pulumi program is composed of a series of steps that define the desired cloud resources using code. You'll need to start by creating a new directory for your program and initializing a new Pulumi project within it.

    mkdir pulumi-trouw-service cd pulumi-trouw-service pulumi new typescript

    After running these commands, you'll have a Pulumi.yaml project file and a index.ts file where you'll write the TypeScript code to deploy the Helm chart.

    Installing Dependencies

    Next, you'll need to install the Pulumi package for managing Rancher resources along with the Kubernetes package.

    npm install @pulumi/rancher2 @pulumi/kubernetes

    Writing the Pulumi Typescript Program

    The index.ts file is where you'll define the Pulumi resources that will deploy your Helm chart. Below is the TypeScript program you can use to accomplish this:

    import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Provide the configuration for the Rancher2 provider. // Ensure that your kubeconfig is properly configured to connect to the Rancher-managed cluster. const provider = new k8s.Provider("rancher-k8s", { kubeconfig: process.env.KUBECONFIG, // Make sure to export your kubeconfig as an environment variable. }); // Define the Helm chart resource. // Replace `chart_repo_url` with the URL of the Helm chart repository and `chart_version` with the desired chart version. const chart = new k8s.helm.v3.Chart("trouw-service-chart", { chart: "trouw-service", version: "chart_version", fetchOpts: { repo: "chart_repo_url", }, // You can add additional configuration such as values to customize the deployment here. // values: { ... }, }, { provider }); // Export the status of the deployment export const deploymentStatus = chart.status;

    Replace chart_repo_url with the actual URL of the Helm chart repository where the trouw-service chart is hosted. Additionally, specify chart_version with the version number of the Helm chart you wish to deploy.

    Understanding the Code

    • The @pulumi/kubernetes package is used to interact with Kubernetes clusters and deploy Kubernetes resources using Pulumi.
    • The @pulumi/pulumi package is the core Pulumi infrastructure-as-code framework.
    • The Provider class configures the Kubernetes provider to connect to your Rancher-managed Kubernetes cluster.
    • The Chart class represents a Helm chart deployment. It is used here to deploy the trouw-service chart to your cluster.
    • The export statement at the end of the program allows you to view the deployment status after running your Pulumi program.

    Running the Pulumi Program

    After writing the program, you can deploy your Helm chart by running these commands:

    pulumi up

    This command will execute your program, which in turn will deploy the Helm chart to your Rancher-managed Kubernetes cluster. It will prompt you to review the changes before performing the deployment.

    After confirming, Pulumi will carry out the necessary steps to deploy the Helm chart.

    Once the deployment is complete, you can check the status of the service using kubectl or the Rancher UI. The export statement will print the deployment status which can be viewed using the Pulumi CLI:

    pulumi stack output deploymentStatus

    This command will return the current status of the Helm chart deployment.


    The program above sets up the Pulumi environment and deploys the trouw-service Helm chart to a Rancher-managed Kubernetes cluster. This process is a starting point for deploying Helm charts with Pulumi. You may need to adjust the configuration and values depending on the specifics of your Helm chart and the Rancher environment. Remember to manage sensitive information such as credentials securely, possibly using Pulumi's secret management capabilities.