Deploy the explorer helm chart on Rancher
TypeScriptTo deploy the Explorer Helm chart on Rancher using Pulumi, you will need to interact with the Rancher2 provider. The provider offers various resources that allow you to manage resources in Rancher, which includes installing Helm charts.
First, make sure you have Rancher up and running, and you have access to it. You should also have a kubeconfig file that allows you to interact with your Kubernetes cluster managed by Rancher.
In the following Pulumi TypeScript program, we will use the
rancher2.CatalogV2
resource to create a catalog for Helm repositories, and then we will use therancher2.AppV2
resource to deploy the Helm chart from the catalog.Here's how you can do this:
- Setup Pulumi: Ensure you have Pulumi CLI installed and configured with access to the Rancher2 provider.
- Install Node.js packages: You will need the
@pulumi/rancher2
package installed in your Node.js project. - Write the deployment script: Use the Pulumi TypeScript SDK to write your deployment script.
- Deploy using Pulumi CLI: Run
pulumi up
to trigger the deployment.
Below is the Pulumi program, which you should run in a directory with a valid
Pulumi.yaml
project file.import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Create a new Rancher2 Catalog V2 const catalog = new rancher2.CatalogV2("explorer-catalog", { clusterId: "<YOUR-CLUSTER-ID>", // Replace with your specific cluster ID url: "https://helm.example.com/", // Replace with the URL of your Helm chart repository gitRepo: "https://github.com/helm/charts.git", // Git repo URL if you are using a git repository gitBranch: "master", // Branch of the git repository }); // Deploy the Explorer Helm chart using the App V2 resource // Note: You'll need to replace `<YOUR-CLUSTER-ID>` with your actual cluster ID const explorerApp = new rancher2.AppV2("explorer", { clusterId: "<YOUR-CLUSTER-ID>", // Cluster ID to deploy to chartName: "explorer", // The name of the chart in the catalog releaseName: "explorer-release", // Release name for the Helm deployment repositoryUrl: catalog.url, // Use the URL from the catalog we created earlier version: "1.0.0", // Specify the version of the Helm chart to deploy namespace: "default", // Kubernetes namespace to deploy the chart into values: // Custom values for the Helm chart configuration ` service: type: ClusterIP ` }); // Export the app name of the deployed Explorer Helm chart export const explorerAppName = explorerApp.metadata.apply(meta => meta.name);
This program performs the following actions:
- It creates a
CatalogV2
resource. This resource points to the repository where your Helm chart is located. Replace<URL-OF-YOUR-HELM-CHART-REPOSITORY>
and<GIT-REPO-URL>
with the URLs to your Helm chart and git repository, respectively. TheclusterId
should be the ID of your Rancher-managed cluster. - It deploys an application using
AppV2
resource. This points to the "explorer" Helm chart in the catalog defined earlier. ThereleaseName
is the name you want to use to track this deployment within Rancher.namespace
should be the Kubernetes namespace where you want to deploy your Helm chart. Thevalues
field is where you can specify custom values for the Helm chart.
Make sure you replace
"<YOUR-CLUSTER-ID>"
with your actual cluster ID. The cluster ID can be obtained from your Rancher dashboard. The version of the Helm chart you want to deploy should be specified in place of"1.0.0"
. You should also replace"https://helm.example.com/"
with the actual URL of your Helm chart repository.To apply this Pulumi configuration:
- Save the code in a
index.ts
file. - Run
npm install
in your project directory to install the dependencies (@pulumi/pulumi
and@pulumi/rancher2
). - Run
pulumi up
to deploy your application.
The
explorerAppName
is exported to make it easy to access and identify the name of your application after deployment, which can be helpful for further automation or verification steps.