1. Deploy the prometheus-process-exporter helm chart on Rancher

    TypeScript

    To deploy the Prometheus Process Exporter Helm chart on a Rancher managed cluster, you need to perform the following steps:

    1. Set up a Rancher-managed Kubernetes cluster: Ensure you have access to a Kubernetes cluster managed by Rancher. If you don't have one, you can create one using Pulumi with the rancher2.Cluster resource.

    2. Install the Rancher2 Pulumi provider: The Rancher2 provider is needed to interact with Rancher resources. You can install it by adding @pulumi/rancher2 to your project using npm or yarn.

    3. Add a Catalog: Before you can deploy a Helm chart on Rancher, the chart's repository needs to be added as a Catalog to Rancher. For the Prometheus Process Exporter, you would add the Prometheus community Helm repo.

    4. Deploy the Helm Chart: Once the Catalog is added, you can deploy the Helm chart by referencing it in a Workload resource from the Rancher2 provider.

    Below is an example TypeScript program that installs the Prometheus Process Exporter using Pulumi:

    import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Replace the values below with the appropriate values for your Rancher setup const rancherClusterId = "my-rancher-cluster-id"; // Your Rancher Cluster ID const prometheusHelmCatalogName = "prometheus-community"; // Name for the Helm catalog in Rancher const prometheusRepoUrl = "https://prometheus-community.github.io/helm-charts"; // Prometheus Helm repo URL const namespaceName = "monitoring"; // The target namespace for the Helm chart // Add the Prometheus Helm repository as a catalog in Rancher const prometheusCatalog = new rancher2.CatalogV2(prometheusHelmCatalogName, { clusterId: rancherClusterId, url: prometheusRepoUrl, gitBranch: "main", }); // Deploy the Prometheus Process Exporter Helm chart const prometheusProcessExporterRelease = new rancher2.AppV2("prometheus-process-exporter", { // Ensure you target the correct cluster clusterId: rancherClusterId, // The namespace where the Helm chart will be installed namespace: namespaceName, // Referencing the catalog added above repoName: prometheusCatalog.name, // The name of the chart in the catalog chartName: "prometheus-process-exporter", // The version of the chart to deploy chartVersion: "0.1.0", // replace with the exact chart version you want to deploy // Values to configure the Prometheus Process Exporter Helm chart values: { // ... insert any chart values here ... }, }); // Export the app name of the chart export const app = prometheusProcessExporterRelease.metadata.apply(m => m.name);

    Explanation:

    • We import the pulumi core module and the rancher2 module at the beginning of the program.

    • The rancherClusterId, prometheusHelmCatalogName, prometheusRepoUrl, and namespaceName variables should be set to match the specifics of your Rancher environment and where you want the Prometheus Process Exporter to be deployed.

    • The prometheusCatalog resource adds the Prometheus community Helm chart repository to Rancher, which allows us to later install charts from this repository.

    • The prometheusProcessExporterRelease resource is responsible for deploying the Prometheus Process Exporter Helm chart onto the Rancher-managed Kubernetes cluster. It references the catalog we added above, the chart name, and the version. You can also specify configuration values to customize the installation of the Helm chart according to your needs within the values property.

    • Finally, we export the name of the deployed app to easily get its identifier within Rancher.

    To run this program, save it to a .ts file, ensure that you have Pulumi and the required NPM packages installed, and then execute it using the pulumi up command. The program will communicate with Rancher, add the Prometheus community Helm repository as a Catalog, and then deploy the Prometheus Process Exporter chart in the specified namespace.