1. Deploy the topology-discovery helm chart on Rancher


    To deploy the topology-discovery helm chart on Rancher using Pulumi, you first need to ensure that you have Rancher set up and that you have access to a Kubernetes cluster where you want to deploy the chart. Pulumi will interact with Rancher to deploy and manage resources within the cluster.

    To accomplish this, we'll use the rancher2 Pulumi provider, which allows for managing Rancher resources. We will use the CatalogV2 and AppV2 resources specifically. The CatalogV2 resource will add the helm chart repository to Rancher if it's not already available, and the AppV2 resource will deploy the topology-discovery chart to your Kubernetes cluster managed by Rancher.

    Here's a step-by-step guide on how to set up the deployment:

    1. Set up Rancher: You should have Rancher installed and a Kubernetes cluster managed by Rancher.
    2. Prerequisites: Ensure kubectl is configured to communicate with the Kubernetes cluster and Pulumi CLI is installed and configured.
    3. Define the Pulumi program: We will create a new Pulumi project using TypeScript.
    4. Import the necessary libraries: We will need @pulumi/pulumi and @pulumi/rancher2.
    5. Create Resources: Define your helm chart configuration and deploy it using Pulumi.

    First, you should set up a new Pulumi TypeScript project if you haven't already:

    pulumi new typescript

    Next, in your Pulumi project, create a new TypeScript file (like index.ts) and add the following code:

    import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Cluster information and helm chart details should be modified according to your setup const clusterId = ""; // Rancher Cluster ID on which you want to deploy your helm chart const topologyDiscoveryChartName = "topology-discovery"; // Name of the helm chart const topologyDiscoveryChartVersion = "x.y.z"; // The version of the helm chart const topologyDiscoveryChartRepoUrl = "http://helm-repository-url/"; // The URL to the helm repository hosting the topology-discovery chart // Create a new catalog (Helm chart repository) in Rancher const catalog = new rancher2.CatalogV2("topology-discovery-catalog", { clusterId: clusterId, url: topologyDiscoveryChartRepoUrl, // If additional configuration is needed, you can modify the spec below }); // Deploy the topology-discovery helm chart const topologyDiscoveryApp = new rancher2.AppV2("topology-discovery-app", { clusterId: clusterId, chartName: topologyDiscoveryChartName, // The namespace should exist in the cluster, you can use a new or existing one namespace: "default", repoName: catalog.metadata.name, chartVersion: topologyDiscoveryChartVersion, // If you need to specify values for the Helm chart, do it within valuesYaml valuesYaml: ` service: type: LoadBalancer replicaCount: 2 `, // Refer to the catalog created above catalogName: catalog.metadata.name, }); // To ensure the catalog resource is created before the app topologyDiscoveryApp.dependsOn = [catalog]; // Export the app URL so we can access it after deployment export const appUrl = topologyDiscoveryApp.status.url;

    This code snippet does the following:

    • Imports the Pulumi SDK and the Rancher2 provider which we'll use to interact with your Rancher-managed Kubernetes cluster.
    • Defines the CatalogV2 resource, which must reference a clusterId variable that corresponds to your Rancher Kubernetes cluster, and the URL to a helm chart repository that holds the topology-discovery helm chart.
    • Defines the AppV2 resource to install the helm chart. It uses the chartName, chartVersion, and clusterId to specify which chart to install on which cluster. The namespace parameter specifies where the chart should be deployed within the cluster (which must already exist), while repoName links to the repository we created previously.
    • The valuesYaml string allows you to specify any custom values to override the default helm values, in this case, what type of Service to expose and the number of replicas.
    • We also mark the chart repository as a dependency for the helm chart installation to ensure the repository is added before the helm chart is deployed.
    • The appUrl is then exported which Pulumi provides as an output once the app is deployed and if it has a reachable URL.

    After setting up your index.ts, run pulumi up from the command line to preview and deploy your stack.

    Keep in mind, that this is a generalized example and some values will depend on your specific infrastructure and the topology-discovery helm chart.

    You would need to install the Rancher2 provider if you haven't already:

    npm install @pulumi/rancher2

    Once the process is complete, the appUrl will give you a way to access the service exposed by the helm chart.

    This is a basic Pulumi program to deploy a helm chart to a Rancher managed cluster. For any specific configuration related to the topology-discovery helm chart, you will have to refer to the chart's values file and replicate the settings you require as valuesYaml.