Deploy the newrelic-private-minion helm chart on Rancher
TypeScriptDeploying a Helm chart on Rancher requires several steps:
- Setting up a Rancher Kubernetes cluster where the Helm chart will be deployed.
- Installing the Rancher2 Pulumi provider that will allow managing resources on Rancher.
- Deploying the Helm chart on the cluster using the Rancher2 provider.
For this particular example, you must already have a Rancher cluster up and running, easily achievable through Rancher's UI or API. I'll show you how to set up the Pulumi code to deploy the
newrelic-private-minion
Helm chart on this existing cluster.Firstly, make sure you have Pulumi installed and configured for use with your desired cloud provider (where your Kubernetes cluster hosted by Rancher is running).
Here is a program in TypeScript that uses the
rancher2
package to deploy a Helm chart on an existing Kubernetes cluster managed by Rancher.import * as rancher2 from "@pulumi/rancher2"; import * as k8s from "@pulumi/kubernetes"; // The following program assumes that you have a Rancher Kubernetes cluster and Rancher API credentials available. // Replace `clusterId` with your actual Rancher Kubernetes cluster ID. const clusterId = "c-xxxxx"; // Using the Rancher2 provider, we can connect to the Rancher instance. // You need to provide it with the URL to your Rancher instance and any necessary credentials. const rancherProvider = new k8s.Provider("rancher-k8s", { kubeconfig: rancher2.getConfig(clusterId).kubeconfig, }); // Define the Helm chart for New Relic Private Minion. // Ensure you have the correct chart name and version. const newRelicMinionChart = new k8s.helm.v3.Chart("newrelic-private-minion", { chart: "newrelic-private-minion", version: "1.0.0", // Replace with the actual chart version fetchOpts:{ repo: "https://helm-charts.newrelic.com", // New Relic's Helm chart repository }, }, { provider: rancherProvider }); // Export the status of the Helm chart deployment. export const status = newRelicMinionChart.status;
In this code:
- We import the necessary Pulumi packages for interacting with Rancher and Kubernetes.
- We create a Kubernetes Provider for Rancher, which is required for deploying resources in the Rancher-managed cluster. You need to replace
clusterId
with the identifier of your Rancher cluster, and make sure your environment is configured with the appropriate credentials to interact with the Rancher API. - We define a Helm chart named
newrelic-private-minion
and fetch it from New Relic's official Helm chart repository. You'll need to replace theversion
field with the exact version number of the chart that you want to deploy. - Finally, we export the status of the Helm chart deployment so you can quickly check if the deployment was successful after running
pulumi up
.
Before running this program, make sure to install the required Node.js packages by running
npm install
oryarn add
for both@pulumi/rancher2
and@pulumi/kubernetes
.npm install @pulumi/rancher2 @pulumi/kubernetes
When you run
pulumi up
with this program, Pulumi will interact with Rancher to retrieve the kubeconfig for the specified cluster and deploy the New Relic Private Minion Helm chart onto that cluster. The deployment will occur based on the current state of the cluster as managed by Rancher.