Deploy the opentelemetry-demo helm chart on Rancher
TypeScriptTo deploy the
opentelemetry-demo
Helm chart on Rancher using Pulumi, you will need to create a Pulumi program that defines the necessary resources. The program will interact with Rancher to create or select a cluster, set up a Helm chart repo (if needed), and deploy the Helm chart. Below you will find a detailed guide and sample Pulumi TypeScript code for this process.Setting up the Rancher Cluster
First things first, you must have a Rancher-managed Kubernetes cluster where you can deploy the Helm chart. You can create a new cluster using Pulumi or use an existing one. In this example, we will assume you have an existing Rancher-managed Kubernetes cluster. If you wanted to create a new cluster, you would use resources such as
rancher2.Cluster
.Adding the Helm Chart Repository
Before deploying the Helm chart, ensure that the repository which contains the
opentelemetry-demo
chart is available in Rancher. You can use therancher2.CatalogV2
resource to add a new catalog if the repo is not already in the list of catalogs on your Rancher server.Deploying the Helm Chart
With the repository in place, you can then deploy the
opentelemetry-demo
Helm chart to your cluster. This will be done using therancher2.AppV2
resource. Helm charts are packaged sets of predefined Kubernetes resources, and by deploying a Helm chart, you are effectively deploying all those resources that make up the application defined in the chart.Prerequisites:
- Pulumi CLI installed
- Pulumi account configured
- Access to a Rancher-managed Kubernetes cluster
rancher2
Pulumi provider configured with appropriate credentials
Sample Pulumi Program
Here's a TypeScript program that adds a Helm chart repository and deploys a Helm chart:
import * as rancher2 from "@pulumi/rancher2"; // Reference to an existing Rancher managed Kubernetes cluster const clusterId = "my-cluster-id"; // Replace with your specific cluster id // Add a Helm chart repository if not already present const helmRepo = new rancher2.CatalogV2("opentelemetry-repo", { // Replace with the URL of the Helm repo that contains the opentelemetry-demo chart url: "https://charts.opentelemetry.io", clusterId, }); // Deploy opentelemetry-demo Helm chart const opentelemetryDemoChart = new rancher2.AppV2("opentelemetry-demo", { clusterId, repoName: helmRepo.name, // Link the App to the repository we set up above chartName: "opentelemetry-demo", namespace: "default", // Deploy in the default namespace or choose your desired one values: { // Provide custom configuration for 'opentelemetry-demo' chart // Example: setting tag to use for opentelemetry collector image // replace this with actual values required for opentelemetry-demo // image: { // tag: "latest" // }, }, }); // Export the name of the chart export const chartName = opentelemetryDemoChart.chartName;
Make sure to replace placeholder values like the
clusterId
with your actual cluster identifier and adjust any fields in thevalues
object with the right configuration foropentelemetry-demo
as needed.Once you have this program, run
pulumi up
to execute it and deploy the Helm chart to your Rancher cluster.Explanation
- We import the
rancher2
module to interact with Rancher's resources. - We reference an existing Rancher-managed cluster by its
clusterId
. - We establish a
CatalogV2
resource, which refers to the repository where the Helm chart is found. - We create a
AppV2
resource, which is responsible for deploying the Helm chart to our referenced cluster. - The
values
parameter is where you customize the deployment properties of your Helm chart. Foropentelemetry-demo
, these properties might include configurations specific to the OpenTelemetry agent/collector setup. - We export the chart name to confirm the Helm release name.
Using Pulumi with Rancher provides an Infrastructure as Code approach to manage and deploy resources within your Kubernetes clusters, offering a repeatable and version-controlled way to automate deployments.