Deploy the webapp-db-java helm chart on Rancher
TypeScriptDeploying a Helm chart on Rancher using Pulumi consists of several steps. First, you'll need to have a Kubernetes cluster managed by Rancher, and then you'll use the Rancher 2 Pulumi provider to deploy your Helm chart into that cluster.
For this example, I will assume you already have a Kubernetes cluster registered with Rancher and that you have set up Pulumi to work with Rancher and Kubernetes. If not, you should:
- Create a Kubernetes cluster.
- Register the cluster with your Rancher instance.
- Install the
rancher2
provider usingnpm install @pulumi/rancher2
. - Ensure your Pulumi environment can authenticate to both Rancher and Kubernetes.
Below is a Pulumi program that demonstrates how to use the
rancher2
provider to deploy a Helm chart to a Kubernetes cluster managed by Rancher. We'll use therancher2.CatalogV2
resource to define a Helm repo, then apply thewebapp-db-java
chart from this repo using therancher2.AppV2
resource.Make sure you replace the
<YOUR_*>
placeholders with your specific values:<YOUR_RANCHER_API_URL>
: The API URL of your Rancher instance.<YOUR_CLUSTER_ID>
: ID of your registered Kubernetes cluster in Rancher.<YOUR_HELM_REPO_URL>
: URL of the Helm repository that contains yourwebapp-db-java
chart.<YOUR_CHART_NAME>
: The name of your chart in the Helm repository.<YOUR_CHART_VERSION>
: The version of the chart you want to deploy.<YOUR_CATALOG_NAME>
: A custom name for your catalog resource in Pulumi.<YOUR_NAMESPACE>
: Kubernetes namespace to which the chart should be deployed.
import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Define the catalog for the Helm chart repository const helmRepo = new rancher2.CatalogV2("webapp-db-java-repo", { url: "<YOUR_HELM_REPO_URL>", clusterId: "<YOUR_CLUSTER_ID>", name: "<YOUR_CATALOG_NAME>", }); // Now deploying the Helm chart to the registered Kubernetes cluster const app = new rancher2.AppV2("webapp-db-java-app", { clusterId: "<YOUR_CLUSTER_ID>", namespace: "<YOUR_NAMESPACE>", repoName: helmRepo.name, chartName: "<YOUR_CHART_NAME>", chartVersion: "<YOUR_CHART_VERSION>", }); // To access the App after it is deployed // Output the App's name, namespace, and repo it was deployed from export const appName = app.name; export const appNamespace = app.namespace; export const appRepoName = app.repoName;
Let me explain the program:
- We import the Pulumi and Rancher2 packages.
- We define a Helm repository catalog resource in Rancher using
CatalogV2
. - We deploy the Helm chart using the
AppV2
resource. It references theCatalogV2
using the repo name to deploy thewebapp-db-java
app. - We export some of the application's details, which provide us with output visible in the Pulumi console after a successful deployment.
Make sure to replace placeholders with the actual values that apply to your setup. Once you run this Pulumi program, it will communicate with Rancher to deploy your Helm chart to your Kubernetes cluster.