Deploy the fdi-eck helm chart on Rancher
TypeScriptDeploying a Helm chart on Rancher using Pulumi involves several steps which require setting up Rancher itself, creating a Kubernetes cluster managed by Rancher, and then deploying the Helm chart into that cluster.
The following Pulumi TypeScript program demonstrates how you would:
- Set up a new Kubernetes cluster using Rancher.
- Deploy the
fdi-eck
Helm chart onto the cluster.
Before running this program:
- Ensure you have installed Pulumi and set up your Pulumi account.
- Make sure you have access to a Rancher instance and have configured Pulumi to use the appropriate credentials via environment variables or configuration settings. You can refer to the Rancher2 provider documentation for more details.
Now let's look at the main parts of this program:
- We're going to use the
rancher2
Pulumi package. This package allows us to interact with Rancher-managed resources. - We'll create a
Cluster
resource which represents a cluster in Rancher. - We'll use the
helm.v3.Chart
resource from the@pulumi/kubernetes
package to deploy a Helm chart onto our cluster.
Here is the Pulumi TypeScript program:
import * as pulumi from '@pulumi/pulumi'; import * as rancher2 from '@pulumi/rancher2'; import * as k8s from '@pulumi/kubernetes'; const clusterName = 'fdi-eck-cluster'; // Create a new Rancher2 cluster const cluster = new rancher2.Cluster(clusterName, { /* Specify cluster configuration here */ }); // Deploy the `fdi-eck` Helm chart on the Rancher-managed cluster const fdiEckChart = new k8s.helm.v3.Chart('fdi-eck', { chart: 'fdi-eck', // Specify the repository options if the `fdi-eck` chart is not in the default repo fetchOpts: { repo: 'http://<helm_chart_repo_url>', }, // Values to pass to the Helm chart values: { // Add extra values here as per the chart's configuration options }, }, { provider: new k8s.Provider('fdi-eck-k8s', { kubeconfig: cluster.kubeConfigRaw }) }); // Export the kubeconfig to access the cluster with kubectl export const kubeConfig = cluster.kubeConfigRaw;
Explanation:
-
rancher2.Cluster
: This resource is a representation of a Kubernetes cluster within Rancher. You need to replace the placeholder/* Specify cluster configuration here */
with actual configuration params such as the node count, network configuration, Rancher project ID, etc., based on what your deployment requires. -
k8s.helm.v3.Chart
: This resource manages a Helm chart's release. Thefdi-eck
here assumes a Helm chart by that name. You'll need to provide the actualchart
name if it's different and specify the correct URL inrepo
where the chart can be found if it's not a part of the Helm stable repository.
Make sure to replace
http://<helm_chart_repo_url>
with the URL of the Helm repository containing thefdi-eck
chart and fill in thevalues
object with the necessary values that configure the Helm chart to your needs.The
kubeconfig
exported by the program can be used to interface with the Kubernetes cluster usingkubectl
once the program has finished running.To run this program:
- Save the above code to a file named
index.ts
in a new Pulumi project directory. - Run
pulumi up
in the same directory to create the resources. - Confirm the preview looks good and then accept the prompt to deploy the resources.
Keep in mind that this program assumes you have the necessary permissions set up in your Rancher server and that the Helm chart
fdi-eck
exists and is available from the specified repository. If additional customization of the cluster or Helm chart deployment is needed, you should adjust theCluster
andChart
resource properties accordingly.