1. Deploy the spot-scheduler helm chart on Rancher


    Deploying a Helm chart on Rancher involves several steps and the use of multiple resources from the rancher2 package. Here's how you can do it with Pulumi and TypeScript. We'll proceed step by step:

    1. Set up the Pulumi project: Make sure you have Pulumi installed, and then create a new project.
    2. Instantiate Rancher: You would need a running Rancher server and sufficient permissions to deploy applications.
    3. Add a Catalog: Helm charts are typically deployed from catalogues in Rancher, so we ensure that the catalog containing spot-scheduler is added.
    4. Deploy the Chart: Once we have the catalog, we deploy the Helm chart to a specific Rancher cluster.

    Here's a Pulumi program that accomplishes this:

    import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Step 1: Set up Rancher provider configuration // Make sure to provide appropriate rancher2 provider configuration. It might involve specifying the Rancher API URL and access keys. // Documentation: https://www.pulumi.com/registry/packages/rancher2/ // Step 2: Add a Catalog // You need to add the correct catalog URL that contains the spot-scheduler chart. const catalog = new rancher2.CatalogV2("spot-scheduler-catalog", { // URL of the catalog from where the spot-scheduler chart can be deployed. url: "https://charts.example.com/", // Replace with the catalog's URL clusterId: "cluster-id", // Replace with your cluster identifier // More properties might be required depending on your authentication method and catalog configuration. // Documentation: https://www.pulumi.com/registry/packages/rancher2/api-docs/catalogv2/ }); // Step 3: Deploy the Chart // Deploy the spot-scheduler helm chart. Detailed configuration may vary based on the chart's values.yaml. const chart = new rancher2.AppV2("spot-scheduler-app", { clusterId: catalog.clusterId, // Using the same clusterId as the catalog namespace: "target-namespace", // Target namespace where you want to deploy your app repoName: catalog.name, // Name of the catalog to use chartName: "spot-scheduler", // Name of the chart to deploy chartVersion: "1.0.0", // Version of the chart values: ``, // YAML string for the Helm chart values, would replace with actual values // Documentation: https://www.pulumi.com/registry/packages/rancher2/api-docs/appv2/ }); // Exporting the App status URL to access after deployment. export const appStatusUrl = pulumi.interpolate`${rancher2.getConfig().apiUrl}/v1/apps/${chart.metadata.name}`;


    • CatalogV2: You must provide the URL to the catalog containing the Helm chart you wish to deploy (spot-scheduler in this case). A catalog in Rancher acts as a repository of Helm charts.
    • AppV2: This is used to deploy applications (Helm charts) into your Rancher Kubernetes clusters. Replace target-namespace with the Kubernetes namespace you wish to deploy the application to.
    • Export: The appStatusUrl export will provide a URL where you can view the status of the deployed application in Rancher's web UI once the Pulumi program is applied.

    Please note that the placeholder values for url, clusterId, and chartVersion as well as any specific configuration in values need to be replaced with the ones appropriate for your setup.

    After you write your TypeScript program file, you can deploy it using the Pulumi CLI:

    pulumi up

    This command starts the deployment process managed by Pulumi, and, if successful, your Helm chart will be deployed to the specified Rancher cluster.

    Keep in mind that you might also need to be authenticated against the Kubernetes cluster managed by Rancher if your Helm chart has any post-deploy scripts that interact with the cluster.