Deploy the stage helm chart on Rancher
TypeScriptTo deploy a Helm chart on Rancher using Pulumi, you'll need to interact with the Rancher2 provider. This provider allows you to manage resources in a Rancher v2.x environment. In the provided scenario, we assume that you have a Rancher server up and running and have access to it.
We will use the following resources:
rancher2.Cluster
: To select the Kubernetes cluster managed by Rancher where the Helm chart will be deployed.rancher2.AppV2
: To define and deploy the Helm chart within the Rancher-managed cluster.
Before you begin, make sure to install the necessary Pulumi providers. For instance, for the Rancher2 provider you can use the following command:
pulumi plugin install resource rancher2 v5.1.1
Here is a basic TypeScript program to deploy a Helm chart named "stage" on a Rancher-managed Kubernetes cluster.
import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Retrieve an existing cluster managed by Rancher const cluster = rancher2.getCluster({ name: "my-cluster", // Replace with the actual cluster name }); // Deploy a Helm chart on the retrieved Rancher cluster const helmChart = new rancher2.AppV2("stage-helm-chart", { repoName: "my-repo", // Replace with your Helm chart's repository name chartName: "stage", // The name of the chart you want to deploy clusterId: cluster.id, // The cluster ID where the chart should be deployed namespace: "default", // The Kubernetes namespace into which the chart should be deployed chartVersion: "1.0.0", // The version of the chart you want to deploy values: { // Values to override defaults in the chart, if needed // key: value, }, }); // Export the URL to access the deployed application, if applicable export const appUrl = pulumi.interpolate`http://${helmChart.status.apply(status => status.url)}`;
In this program, replace
"my-cluster"
,"my-repo"
, and other placeholders with the correct values that apply to your Rancher setup, Helm chart repository, and specific Helm chart details.Ensure that you have the required access permissions for the Rancher cluster, and that your Pulumi stack is configured with the appropriate credentials to interact with your Rancher server.
This Pulumi program does the following:
- It imports the necessary Pulumi libraries.
- Fetches the desired Rancher cluster where you want to deploy the Helm chart.
- Creates a new
AppV2
resource, which corresponds to the Helm chart to be deployed on the specified Rancher-managed Kubernetes cluster.
Please ensure you have the
@pulumi/rancher2
package installed in your project:npm install @pulumi/rancher2
When you run this code with
pulumi up
, it will deploy the specified Helm chart to your Rancher-managed Kubernetes cluster. TheappUrl
export can be used to retrieve the URL to access the application, if applicable.The actual Helm chart and configuration values would depend on your particular application's requirements and the structure of the chart itself. Adjust the
values
property of theAppV2
resource accordingly.