Deploy the public-html helm chart on Rancher
TypeScriptIn this program, we'll deploy a Helm chart to a Rancher Kubernetes cluster. Rancher is an open-source multi-cluster orchestration platform that streamlines Kubernetes cluster management. You can apply Kubernetes resources to your cluster using Pulumi and the
rancher2
package, which allows for direct interaction with the Rancher instance.We'll leverage Pulumi's
rancher2
provider to deploy thepublic-html
Helm chart. Typically, to do this using Pulumi, you need to perform the following steps:- Set up a Pulumi project and stack.
- Install and import the
rancher2
package. - Authenticate with your Rancher server instance.
- Define the Rancher Kubernetes cluster where you wish to deploy your Helm chart.
- Create a
CatalogV2
resource which is a collection of asset definitions that enable you to deploy collections of services. - Define a
HelmChart
resource within a target namespace on your Kubernetes cluster.
Before you proceed, make sure you have:
- A Pulumi account, with the Pulumi CLI installed and set up.
- Access to a Rancher server with at least one Kubernetes cluster deployed.
Below is the program written in TypeScript to deploy the
public-html
Helm chart using Rancher with Pulumi. I'm using fictional placeholders for sensitive information such asrancherApiUrl
,accessToken
, andclusterId
— you should replace these with your Rancher instance details.import * as rancher2 from "@pulumi/rancher2"; // Replace these variables with your own values. const rancherServerUrl = "https://example-rancher-server.com"; // Your Rancher server URL const accessToken = "token-xxxx"; // Your Rancher access token const clusterId = "c-xxxxx"; // The ID of your Rancher Kubernetes cluster // Configure the Rancher2 provider with the required credentials. // It's recommended to use Pulumi's configuration system for storing sensitive information. const rancherProvider = new rancher2.Provider("rancherProvider", { apiUrl: rancherServerUrl, tokenKey: accessToken, }); // Provision a new Catalog V2 which will contain the repository where the public-html chart is located. const catalog = new rancher2.CatalogV2("publicHtmlCatalog", { clusterId: clusterId, url: "https://charts.example.com/", // Replace with the Helm chart repository URL // This assumes you're adding a global catalog. For project-specific catalogs, use the appropriate project ID instead. }, { provider: rancherProvider }); // Deploy the public-html Helm chart from the catalog to the specified cluster. const publicHtmlHelmChart = new rancher2.HelmChart("publicHtmlHelmChart", { clusterId: clusterId, repository: catalog.name, chart: "public-html", // The name of the chart in the repository namespace: "default", // Specify the namespace where the chart should be installed // If the Helm chart requires additional values, specify them as below. // values: { // key: "value", // }, }, { provider: rancherProvider }); // Export the name of the catalog and Helm chart export const catalogName = catalog.name; export const helmChartName = publicHtmlHelmChart.name;
This program configures the
rancher2
provider to authenticate against your Rancher server, then it sets up a catalog pointing to a Helm chart repository. After that, it deploys a Helm chart namedpublic-html
to the default namespace within your specified Kubernetes cluster. If your Helm chart requires additional values to customize its deployment, you can provide them in thevalues
argument for theHelmChart
resource.Make sure to substitute the
rancherServerUrl
,accessToken
, andclusterId
with your Rancher server's endpoint, a valid token, and the cluster ID where the Helm chart should be deployed.Also, please ensure the Helm chart repository URL you specify in the
CatalogV2
resource is the correct location where thepublic-html
Helm chart resides.After you've written your Pulumi program, you deploy it by running
pulumi up
from within your project directory. The command will output any resources being created along with a summary of the deployment.When you're ready to remove the deployed Helm chart and the catalog, you can destroy the Pulumi stack resources by running
pulumi destroy
. This will prompt you before deleting resources from your cloud provider.