Deploy the wallet-component helm chart on Rancher
TypeScriptTo deploy a Helm chart on a Rancher Kubernetes cluster using Pulumi, you first need to have a Kubernetes cluster managed by Rancher and the Helm chart you want to deploy. Here we will focus on deploying an existing Helm chart onto a Rancher-managed cluster. We will use the
rancher2
Pulumi provider to interact with Rancher.In this example, we will assume:
- You have a Rancher-managed Kubernetes cluster available.
- The Helm chart named
wallet-component
is stored in a Helm repository that is accessible from your Kubernetes cluster.
We will go through the following steps in the code:
- Set up the Rancher 2 provider to configure the access to the Rancher API.
- Deploy the Helm chart to the Rancher-managed cluster using the
helm.v3.Chart
resource.
First, install the necessary Pulumi packages by running these commands in your Pulumi project's directory:
pulumi plugin install resource rancher2 <version> npm install @pulumi/kubernetes npm install @pulumi/rancher2
Replace
<version>
with the appropriate version of the Rancher2 provider.Now, let's write the Pulumi program in TypeScript:
import * as rancher2 from "@pulumi/rancher2"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Configure Rancher provider settings const rancherProvider = new rancher2.Provider("rancher", { apiUrl: "https://rancher.my-company.com/v3", accessKey: "RANCHER_ACCESS_KEY", secretKey: "RANCHER_SECRET_KEY", }); // Step 2: Use the Kubernetes provider configured to target the Rancher-managed cluster const k8sProvider = new k8s.Provider("k8s", { kubeconfig: rancherProvider.kubeconfig.apply(kubeconfig => kubeconfig), }, { dependsOn: rancherProvider }); // The name of your Rancher cluster const clusterName = "my-cluster"; // Step 3: Deploy the wallet-component helm chart from the Helm repository const walletComponentChart = new k8s.helm.v3.Chart("wallet-component", { chart: "wallet-component", version: "1.2.3", // replace with the version of the chart you want to deploy fetchOpts: { repo: "http://helm-repository.example.com/", // replace with the URL of your Helm repository } }, { provider: k8sProvider }); // Export the status of the deployment export const walletComponentStatus = walletComponentChart.status;
Here is what we did in the code above:
- Imported the required Pulumi modules for Rancher and Kubernetes.
- Configured the Rancher provider with the API URL and credentials.
- Created a Kubernetes provider instance that is configured to target the Rancher-managed cluster based on the kubeconfig provided by the Rancher provider.
- Deployed the
wallet-component
chart using the Helm chart resource. Thechart
parameter specifies the name of the Helm chart, andfetchOpts
is used to specify the repository where the chart is located. - The chart's version is specified, which should match the version you want to deploy.
- We export the status of the Helm chart deployment, which can be queried with
pulumi stack output
after the deployment.
Remember to replace the values of
apiUrl
,accessKey
,secretKey
, the chartversion
, and therepo
URL with your actual Rancher API details, Rancher access and secret keys, the version of the Helm chart you wish to deploy, and the location of your Helm repository.To deploy this Pulumi program:
- Save the code in a file with a
.ts
extension, for example,index.ts
. - Run
pulumi up
to preview and deploy the resources.
I hope this helps! If you have more questions or need further assistance, feel free to ask.