1. Deploy the ngingo helm chart on Rancher


    Deploying a Helm chart on a Kubernetes cluster managed by Rancher involves several steps. Using Pulumi, you can automate the provisioning and management of Kubernetes resources, including deploying applications using Helm charts.

    Below is the TypeScript program that demonstrates how to deploy a Helm chart on a Kubernetes cluster managed by Rancher. The program assumes that you have already set up Rancher with a Kubernetes cluster and have configured Pulumi to use the appropriate credentials for your Rancher server.

    The program performs the following steps:

    1. It imports the necessary Pulumi packages for interacting with Rancher.
    2. It creates a CatalogV2 resource, assuming you have a Helm chart repository.
    3. It deploys the Helm chart named 'ngingo' to the Kubernetes cluster using the rancher2.AppV2 resource.

    Before you run this program, you must have Pulumi and Rancher2 installed, and you need to be authenticated with both.

    import * as rancher2 from "@pulumi/rancher2"; import * as k8s from "@pulumi/kubernetes"; // Replace these values with the correct ones for your Rancher setup const CATALOG_NAME = "my-catalog"; const CATALOG_URL = "https://charts.example.com/"; const CHART_NAME = "ngingo"; const CHART_VERSION = "1.0.0"; // Replace with your chart's version const PROJECT_ID = "c-xxxxx:p-yyyyy"; // Replace with your Rancher project ID const NAMESPACE = "default"; // Replace with the target namespace for your helm chart // Create a Catalog V2 which contains the Helm chart repository link. // It is a collection of Helm charts that can be accessed within Rancher. const catalog = new rancher2.CatalogV2(CATALOG_NAME, { url: CATALOG_URL }); // Deploy the Helm chart to the Rancher-managed Kubernetes cluster. // This resource represents the Helm chart that will be deployed. const app = new rancher2.AppV2(CHART_NAME, { repoName: catalog.name, chartName: CHART_NAME, chartVersion: CHART_VERSION, projectId: PROJECT_ID, namespace: NAMESPACE }); // Export the URL of the app export const appUrl: pulumi.Output<string> = app.status.apply(status => { // This depends on how your Helm chart exposes the application, you may need to modify this. const ingress = status?.resources?.find(r => r.kind === "Ingress"); return ingress ? `http://${ingress?.name}.${NAMESPACE}.svc.cluster.local` : "not-ready"; });

    Here is a brief explanation of the Pulumi resources used in this program:

    • rancher2.CatalogV2: Represents a Helm chart repository in Rancher. This resource will add a Helm chart repository to Rancher where it can manage charts.

    • rancher2.AppV2: Represents a deployment of a Helm chart. This will cause Rancher to deploy the specified Helm chart into the Kubernetes cluster associated with the given project ID.

    Remember that the above appUrl export assumes the Helm chart deploys an Ingress and uses a particular naming convention to expose the service. Replace the logic for deriving the appUrl with the actual way your app gets exposed via the Helm chart.

    Please also note that because deploying a Helm chart is an async operation, you may see your Pulumi program complete execution while the resources are still being created by Rancher in the cluster. You can confirm the status of the deployment directly from the Rancher UI or by using kubectl to query your cluster.