1. Deploy the common-library helm chart on Rancher

    TypeScript

    To deploy a Helm chart on Rancher using Pulumi, you need to understand how Helm and Rancher integrate. Helm is a package manager for Kubernetes applications, which allows you to define, install, and upgrade even the most complex Kubernetes applications. Rancher is an open-source multi-cluster management platform that supports Kubernetes.

    To accomplish your goal using Pulumi, we'll use the rancher2 Pulumi provider. This provider allows us to manage Rancher resources using Pulumi. We will deploy a new Helm chart, presumably named "common-library," which will be treated as an application within the Rancher context.

    Here's a general outline of the steps we'll take in the Pulumi program:

    1. Set up the rancher2 provider to communicate with your Rancher server.
    2. Specify the Rancher cluster where you want to deploy the Helm chart.
    3. Deploy the Helm chart using CatalogV2.

    Below is a Pulumi program in TypeScript that demonstrates these steps. Before you run this program, ensure that you've set up your Rancher environment correctly and have access to the Rancher API.

    import * as rancher2 from "@pulumi/rancher2"; import * as pulumi from "@pulumi/pulumi"; // Create a new Rancher2 Catalog V2 for the common-library helm chart. // This will add the catalog to the available set of catalogs in Rancher. const catalog = new rancher2.CatalogV2("common-library-catalog", { // Replace the following properties with the actual details of your Helm chart repository url: "https://charts.your-repo.com/", // URL to your Helm chart repository clusterId: "cluster-id", // The ID of the cluster where you want to deploy the Helm chart gitRepo: "https://github.com/helm/charts", // Git repository holding the chart (if applicable) gitBranch: "main", // Git branch where the chart is located (if applicable) }); // Deploy the common-library Helm chart into the Kubernetes cluster managed by Rancher. const app = new rancher2.AppV2("common-library", { // The chart name and version should reflect the actual chart you wish to deploy chartName: "common-library", chartVersion: "1.0.0", // Use the version of the chart you want to deploy clusterId: "cluster-id", // Specify the same clusterId from earlier namespace: "default", // The Kubernetes namespace to deploy into, replace if different repoName: catalog.name, // Refer to the previously created catalog // Values for the Helm chart in YAML format (as string), or a map of the values values: ` someKey: someValue anotherKey: anotherValue `, }); // Export the name of the catalog and app as a stack output export const catalogName = catalog.name; export const appName = app.name;
    • rancher2.CatalogV2: Represents a Helm chart repository (i.e., a Catalog) in Rancher. You need to provide the URL to your Helm chart repository, and the cluster ID where you want to deploy the Helm chart from the repository. Optionally, you can specify a Git repository and branch if your catalog is sourced from there.

    • rancher2.AppV2: Represents a Helm chart deployment within Rancher. After specifying the necessary fields like chart name, version, and cluster ID, you can provide custom values to the chart using the values field. These values customize the deployment of the Helm chart.

    Remember to replace placeholder values such as URLs, cluster ID, and chart details with the actual values from your environment. Also, ensure that the version number of "common-library" reflects the one you intend to use.

    After setting up the program, run it with Pulumi CLI to deploy your Helm chart on Rancher. Pulumi will communicate with Rancher to create these resources on your behalf.