1. Deploy the turbonomic-importer helm chart on Rancher


    To deploy the turbonomic-importer helm chart on a Rancher-managed Kubernetes cluster, you must first have access to a Rancher server and a cluster managed by Rancher where you would like to deploy the Helm chart. Pulumi provides a resource named rancher2.AppV2 within the rancher2 package which represents a multi-cluster app deployed to a set of namespaces within the Kubernetes cluster(s).

    In the following program, I am going to guide you through the use of Pulumi's rancher2 provider to deploy a Helm chart to a Rancher-managed cluster. Pulumi will communicate with your Rancher server using its API, so you need to have the hostname of the Rancher server, an API token, and the cluster identifier where you want to install the chart.

    You also need to ensure that you have the Helm repository added to your Rancher server, so it knows where to fetch the turbonomic-importer chart from.

    Here's a step-by-step TypeScript program that you can use to deploy a Helm chart in Rancher:

    1. Import necessary packages.
    2. Create a new rancher2 provider instance to interact with your Rancher server.
    3. Deploy the Helm chart using rancher2.AppV2.

    Below is the Pulumi program to achieve this:

    import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Step 1: Ensure you set up the Rancher provider with proper credentials. // These can be sourced from environment variables or Pulumi config. // The API token should have permissions to manage apps in the targeted cluster. const provider = new rancher2.Provider("rancher", { apiToken: "myRancherApiToken", // Replace with your Rancher API token baseUrl: "https://rancher.my.org", // Replace with your Rancher server URL }); // Step 2: Ensure you have the catalog that contains the turbonomic-importer Helm chart. // This adds the catalog to Rancher if it's not already added. Here we assume it's a public catalog. const catalog = new rancher2.CatalogV2("turbonomic-catalog", { clusterId: "c-m-abcdefgh", // Replace with your targeted cluster ID url: "https://charts.turbonomic.com", // The Helm repository URL where the chart is located }, { provider }); // Step 3: Deploy the turbonomic-importer Helm chart using the AppV2 resource. // Replace 'namespaceName' with the name of the namespace where you want to deploy the chart. // If this namespace does not exist, you should create it using the rancher2.Namespace resource. const app = new rancher2.AppV2("turbonomic-importer-app", { clusterId: catalog.clusterId, repoName: catalog.name, chartName: "turbonomic-importer", // The name of the chart in the catalog namespace: "default", // The target namespace within the cluster values: { // Chart values // Set your Helm chart values here. This will be specific to the turbonomic-importer chart. // For example: // image: { // repository: "turbonomic/importer", // tag: "latest" // }, // service: { // type: "ClusterIP", // port: 80 // }, }, }, { provider }); // Export the app namespace and name, which can be used to query the app status via `kubectl` or Rancher UI. export const appNamespace = app.namespace; export const appName = app.name;

    Understanding the Code

    • Provider Configuration: The program starts by creating a new rancher2.Provider instance, which is required to interact with your Rancher server. It uses API tokens for authentication.

    • Catalog Addition: Before you can deploy a chart, you often need to add its repository as a catalog in Rancher. The rancher2.CatalogV2 resource represents a Helm chart repository in Rancher. When you instantiate this resource, Pulumi ensures that the specified catalog is present in your Rancher server.

    • App Deployment: With the catalog in place, you can use the rancher2.AppV2 resource to deploy the chart in your cluster. This resource requires the chart name, the catalog name, and the target namespace in its configuration. You can also specify chart values using the values property.

    • Exports: The program concludes by exporting two outputs, the appNamespace and appName. These outputs can be helpful when you want to check the application status or manage it using kubectl commands.

    Make sure to replace "myRancherApiToken", "https://rancher.my.org", and "c-m-abcdefgh" with your actual Rancher API token, the URL of your Rancher server, and your targeted cluster identifier, respectively. Adjust the chart values field according to the turbonomic-importer Helm chart's specifications, which can be found in the chart's documentation.

    After writing this code to a file, you can run pulumi up to execute it and deploy the Helm chart to your Rancher cluster. Remember to check the Helm chart's documentation for any other dependencies or prerequisites that need to be addressed before deployment.