1. Deploy the tiny-api-chart helm chart on Rancher


    Deploying Helm charts on a Rancher-managed Kubernetes cluster involves several steps, including setting up the Rancher provider, creating a Kubernetes cluster where the Helm chart will be deployed, and then deploying the chart itself. Below is a detailed explanation of how you can accomplish this using Pulumi with TypeScript.

    Explanation of Resources:

    1. rancher2.Cluster: Represents a Kubernetes cluster in Rancher. We need a cluster where we can deploy our Helm chart.
    2. rancher2.CatalogV2: Represents a catalog in Rancher which could contain our Helm chart. Helm charts can be pulled from various repositories which should be registered as catalogs in Rancher.
    3. helm.v3.Release from the @pulumi/kubernetes package: Represents a Helm chart deployment. It's used to deploy a Helm chart to a Kubernetes cluster.


    • Have access to a Rancher server.
    • Have a Helm chart repository with tiny-api-chart available to Rancher.
    • Be authenticated with Rancher API (usually via a token).

    Let's start by setting up the providers and resources to deploy the tiny-api-chart Helm chart on a Rancher managed cluster.

    import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; import * as k8s from "@pulumi/kubernetes"; // Create a new rancher2 provider instance const rancherProvider = new rancher2.Provider("rancherProvider", { apiURL: "https://<Rancher_Server_URL>", accessToken: "<Access_Token>", secretKey: "<Secret_Key>", }); // Provision the cluster to deploy the Helm chart on const cluster = new rancher2.Cluster("tiny-api-cluster", { // Replace with your desired cluster configuration // ... }, { provider: rancherProvider }); // Add a catalog that contains the Helm chart you want to deploy const catalog = new rancher2.CatalogV2("helm-catalog", { // Replace with your catalog's URL and details // ... clusterId: cluster.id, }, { provider: rancherProvider }); // Set up the k8s provider to interact with the deployed cluster const k8sProvider = new k8s.Provider("k8s", { kubeconfig: cluster.kubeConfig, // Get the kubeconfig from the created cluster }); // Deploy the tiny-api-chart Helm chart within the created cluster const tinyApiChart = new k8s.helm.v3.Release("tiny-api-chart", { chart: "tiny-api-chart", version: "1.0.0", // Use the version of the chart you intend to deploy repositoryOpts: { repo: "http://<Your_Helm_Chart_Repo_URL>", // The URL of the Helm chart repository }, }, { provider: k8sProvider }); // Export the cluster name and the Helm chart deployment name export const clusterName = cluster.name; export const tinyApiChartName = tinyApiChart.name;

    In the above program:

    • We first create a new instance of the Rancher provider using the Rancher API URL and credentials.
    • Then we set up a Kubernetes cluster resource where we will deploy our Helm chart. You would need to replace the commented part with your specific cluster configuration parameters.
    • A Helm chart catalog (rancher2.CatalogV2) is added so Rancher knows where to fetch the chart from. This catalog should include the tiny-api-chart.
    • We instantiate a Kubernetes provider that utilizes the kubeconfig from our Rancher-managed cluster.
    • Finally, we deploy the Helm chart using the Kubernetes provider. The chart's name, version, and repository URL are specified accordingly. Ensure these match your Helm chart details.
    • The program exports the cluster name and the Helm chart release name for reference.

    You would need to replace the placeholders (including <Rancher_Server_URL>, <Access_Token>, <Secret_Key>, <Your_Helm_Chart_Repo_URL>, etc.) with your actual values to make the code operational. Make sure you've set up the credentials as environment variables or through some secure way if you're working in a shared/production environment.