Deploy the workflow helm chart on Rancher
TypeScriptTo deploy a Helm chart on Rancher using Pulumi, you will need to interact with Rancher's Kubernetes clusters. Pulumi's Rancher2 provider will allow us to manipulate resources within Rancher. In this example, we will use the
rancher2.App
resource to deploy a Helm chart. This resource represents an application installed via Helm into a Rancher cluster.First, you'd need to set up Rancher and have a cluster ready to use. Once you have that, you can use Pulumi with the Rancher2 provider to deploy a Helm chart as an app on your Rancher-managed Kubernetes cluster.
Here's a step-by-step guide in TypeScript on how to deploy a Workflow Helm chart to a Rancher Kubernetes cluster:
-
Pulumi Stack Initialization: Begin by creating a new Pulumi project and stack if you haven't already.
-
Provider Setup: Configure the Pulumi stack to use the Rancher2 provider.
-
Cluster Reference: Obtain a reference to the Rancher Kubernetes cluster where you'll deploy your Helm chart.
-
Deploying the Helm Chart: Define a Helm chart resource for Workflow and configure it to be managed by Rancher.
Below is the Pulumi TypeScript code that performs these steps:
import * as pulumi from "@pulumi/pulumi"; import * as rancher2 from "@pulumi/rancher2"; // Before running the code make sure to set up Pulumi to work with your Rancher instance // and configure the Pulumi Rancher2 provider with appropriate API keys. // Replace 'workflow' with the name of your Helm chart. const workflowHelmChartName = "workflow"; // Replace these values with appropriate references to the target Rancher cluster // and namespace where the Helm chart should be deployed. const targetClusterId = "<YOUR-RANCHER-CLUSTER-ID>"; const targetNamespace = "<YOUR-KUBERNETES-NAMESPACE>"; // Deploying the Workflow Helm chart as an application on Rancher. const workflowApp = new rancher2.App(workflowHelmChartName, { // This assumes the Helm chart is in the default Helm chart repository. // If the chart is in a custom repository, the catalog name and version will be necessary. catalogName: "library", // Name of the catalog. Replace if your chart is in a different catalog. clusterId: targetClusterId, description: "Workflow application", // Description for the application. // You may need to tailor the following property to your Helm chart requirements. // This is the values.yml content for your chart. valuesYaml: ` replicaCount: 2 service: type: LoadBalancer `, // Target namespace where the Helm chart will be deployed. // Your Rancher Kubernetes cluster must have this namespace created. targetNamespace: targetNamespace, }); // Exporting the application ID so that we can easily access it if needed. export const workflowAppId = workflowApp.id;
This code will deploy the "workflow" Helm chart into the specified cluster and namespace on Rancher. Make sure you replace the placeholders with the actual IDs and names that correspond to your Rancher setup.
Here's what the code is doing:
- I am importing the required modules from the Pulumi library and the Rancher2 provider.
- I am configuring a
rancher2.App
resource, which represents a Helm chart deployment in Rancher. - In the
valuesYaml
property, I include the configuration typically found in a Helm chart'svalues.yml
file. This will configure the deployed application according to your needs. - Finally, I export the ID of the application so that it can be referred to or managed later.
Before running this Pulumi program, ensure you have set up your Pulumi environment with authentication to your Rancher server and have the correct access rights to deploy applications on the target cluster.
To run the program, navigate to the directory containing the Pulumi program and execute the following commands:
pulumi up
This command starts the Pulumi deployment process, which will review your code, give you a preview of the changes, and ask for confirmation before proceeding to apply those changes.
Please replace placeholders, such as
<YOUR-RANCHER-CLUSTER-ID>
and<YOUR-KUBERNETES-NAMESPACE>
, with actual values from your Rancher environment setup. Have the necessary configuration and credentials ready for Rancher to avoid any access issues.Remember, before executing the Pulumi program, ensure that the Pulumi CLI is installed, and you are logged in with
pulumi login
. Additionally, you'll want to be sure your environment is set up to communicate with your Rancher instance (usually this involves configuring an API token and endpoint).-