1. Deploy the kyso-api helm chart on Rancher

    TypeScript

    Deploying the kyso-api Helm chart on a Rancher-managed Kubernetes cluster involves several steps. First, you need to have Rancher set up and managing a Kubernetes cluster where the Helm chart will be deployed. Second, you will need to have Helm configured with the Rancher Kubernetes cluster's context so that you can deploy charts directly to it.

    Below, the TypeScript program with Pulumi utilizes resources from the rancher2 package to manage a Helm chart deployment. This example will not configure the entire Rancher setup or Kubernetes cluster, as these are complex tasks that usually happen outside of typical Pulumi management scripts. Instead, I will show you how to define a Pulumi program that could deploy a hypothetical kyso-api Helm chart to an existing Rancher cluster and namespace. We will assume that the Helm chart is available in a Helm repository.

    import * as rancher2 from "@pulumi/rancher2"; import * as k8s from "@pulumi/kubernetes"; // If you have not yet installed the Pulumi Rancher2 provider, you need to do so first. // You can add it to your Pulumi project using the following command: // `pulumi plugin install resource rancher2 <VERSION>` // Create a new Rancher2 client to interact with the Rancher API. const rancherClient = new rancher2.Provider("rancher-provider", { api_url: "https://rancher.my-domain.com/v3/", accessKey: "your-rancher-access-key", secretKey: "your-rancher-secret-key", // Pulumi will use these credentials to authenticate requests to the Rancher server. }); // Retrieve the existing Rancher-managed Kubernetes cluster resource. // Replace `existing-cluster-id` with the actual ID of your Rancher-managed cluster. const cluster = rancher2.getCluster({ id: "existing-cluster-id" }, { provider: rancherClient }); // Retrieve the existing namespace where the Helm chart will be deployed. // Replace `existing-namespace-id` with the actual ID of your namespace within the Rancher-managed cluster. const namespace = rancher2.getNamespace({ id: "existing-namespace-id" }, { provider: rancherClient }); // Deploy the kyso-api Helm chart using the rancher2.HelmChart resource from the Pulumi Rancher2 provider. const kysoApiChart = new rancher2.HelmChart("kyso-api-chart", { // Assuming the kyso-api chart is in a repository added to Rancher chartName: "kyso-api", repoUrl: "https://helm-repo.example.com/charts", version: "1.2.3", // replace with the actual chart version resetValues: true, clusterId: cluster.id, namespaceId: namespace.id, // Other values for customizing the kyso-api deployment can go here. set: { "service.type": "ClusterIP", "image.tag": "latest" }, }, { provider: rancherClient }); // Export the name of the chart, which can be useful when querying the deployment later. export const chartName = kysoApiChart.name; // This is a basic example, in real-world usage, you may need to provide more specific configuration // for the `kyso-api` chart including dependencies, secret configuration, custom service endpoints, etc.

    Explanation:

    • We first import the requisite Pulumi packages for interacting with Rancher (@pulumi/rancher2) and Kubernetes (@pulumi/kubernetes).

    • We create a new Provider which configures Pulumi to use the Rancher API. The credentials (accessKey and secretKey) will need to be replaced with your actual Rancher credentials. The api_url should be the URL to your Rancher server.

    • We use getCluster and getNamespace to reference existing cluster and namespace resources managed by Rancher. You will need to provide the actual IDs for your cluster and namespace.

    • We define a HelmChart resource for deploying the kyso-api chart from the specified Helm repository.

    • We use the set property to configure specific values that the kyso-api chart requires. This would be similar to using the --set command-line argument with Helm. You will need to replace the values with those appropriate to the kyso-api chart you want to deploy.

    • The export const chartName statement allows you to export the name of the deployed Helm chart, so you can reference it in other parts of your Pulumi program, or in subsequent Pulumi commands such as pulumi stack output.

    • This example assumes you have an existing cluster and namespace. Managing these resources is typically done via the Rancher UI or through more extensive Pulumi scripts that set up your infrastructure.

    Before running this Pulumi program, make sure you have installed the necessary Pulumi provider plugins and authenticated Pulumi with your Rancher credentials. If you're new to Pulumi, please refer to Pulumi's getting started documentation for your specific cloud provider.