Deploy the pdf-rendering-srv helm chart on Rancher
TypeScriptDeploying a Helm chart in a Rancher-managed Kubernetes cluster involves a few steps. We’ll use Pulumi's Rancher2 provider to accomplish this. Here’s how the general process looks:
- Setting Up the Rancher Provider: Pulumi needs to authenticate with the Rancher server. This typically involves setting up credentials like access keys.
- Finding the Cluster: You need to identify which Kubernetes cluster you wish to deploy the Helm chart on. This might involve fetching the cluster by its ID or name.
- Deploying the Helm Chart: Using the appropriate Pulumi resources, we'll deploy the Helm chart to the selected cluster.
The Pulumi Rancher2 provider does not have a dedicated resource for deploying Helm charts directly, so we will need to use a combination of a
CatalogV2
to define the source of the Helm chart followed by aAppV2
to deploy it in the cluster.Before you use the code, make sure you have installed the Pulumi CLI and the Rancher2 provider. Configure your Pulumi environment with Rancher2 credentials.
The following program is written in TypeScript and assumes all necessary configurations and credentials are set up in the Pulumi environment. Replace placeholder texts like
<RANCHER_ACCESS_KEY>
and<RANCHER_SECRET_KEY>
with your actual Rancher access and secret keys.import * as rancher2 from "@pulumi/rancher2"; // Set Rancher API access configurations const rancherAccessKey = "<RANCHER_ACCESS_KEY>"; const rancherSecretKey = "<RANCHER_SECRET_KEY>"; const rancherApiUrl = "https://your-rancher-api-url"; // Replace with your Rancher API URL const provider = new rancher2.Provider("rancher", { apiURL: rancherApiUrl, accessKey: rancherAccessKey, secretKey: rancherSecretKey, }); // Set up a Rancher Catalog V2 for the pdf-rendering-srv chart repository const pdfRenderCatalog = new rancher2.CatalogV2("pdf-rendering-catalog", { name: "pdf-rendering-service", url: "https://helm-repo-containing-pdf-rendering-srv", // Replace with actual repo URL clusterId: "cluster-id", // Replace with your Rancher Cluster ID }, { provider: provider }); // Deploy the pdf-rendering-srv Helm chart in the specified cluster const pdfRenderApp = new rancher2.AppV2("pdf-rendering-app", { name: "pdf-rendering-srv", catalogName: pdfRenderCatalog.name, clusterId: "cluster-id", // Replace with your Rancher Cluster ID namespace: "default", repoName: "catalog-name", // Replace with the name of your Helm chart repository chartName: "pdf-rendering-srv", chartVersion: "chart-version", // Replace with the chart version },{ provider: provider, }); // Export the app's name export const appName = pdfRenderApp.name;
Explanation of resources and their purposes:
rancher2.Provider
: Initializes the Rancher provider with the API URL and credentials.rancher2.CatalogV2
: Represents a catalog source where the Helm chart resides. This needs to be set up before deploying an app using that catalog.rancher2.AppV2
: Represents the actual deployment of the Helm chart on a Rancher-managed Kubernetes cluster.
Keep in mind that you'll need to replace placeholder texts with actual URLs, chart names, versions, and your cluster information. Run
pulumi up
to apply the above code and deploy your chart.Please note that Cluster ID and other specific identifiers need to be fetched from your existing Rancher setup. They can often be found in the Rancher UI or by querying the Rancher API.
Important: Make sure you have permissions to access the Rancher API and interact with the cluster resources. This Pulumi program does not include error handling or complex deployment configurations but is meant to demonstrate the main process for deploying a Helm chart to a Rancher cluster.