Deploy the tyk-dev-portal helm chart on Rancher
TypeScriptTo deploy a Helm chart on a Rancher-managed Kubernetes cluster, you will need to follow these steps:
-
Set up a Rancher Cluster: You should have access to a Rancher cluster. If you do not have an existing cluster, you can create one using the
rancher2.Cluster
resource. -
Add a Catalog: Rancher uses catalogs to organize and manage Helm charts. Before deploying a Helm chart, you must ensure that the chart's repository has been added to Rancher's catalogs using the
rancher2.CatalogV2
resource. -
Deploy the Helm Chart: After the catalog is added, use the
helm
package provided by Pulumi to deploy the Helm chart to the Rancher cluster.
We'll go through each step in the Pulumi TypeScript program below. This program assumes that you have configured your Pulumi CLI and have the necessary permissions to interact with the Rancher API.
Please make sure you have installed
@pulumi/rancher2
and@pulumi/helm
npm packages before running the code.import * as rancher2 from '@pulumi/rancher2'; import * as helm from '@pulumi/helm'; import * as pulumi from '@pulumi/pulumi'; // Step 1: Ensure you have a Rancher2 cluster set up // You can use `rancher2.Cluster` resource to create a new cluster if needed // For this example, we'll assume a pre-existing cluster identified by 'clusterId' const clusterId = 'your-cluster-id'; // Replace with your actual cluster ID // Step 2: Add the Helm chart repository to Rancher's catalog const catalog = new rancher2.CatalogV2('tyk-dev-portal-catalog', { clusterId: clusterId, url: "https://helm.tyk.io/public/helm/charts/", // URL of the Tyk Helm chart repository }); // Step 3: Deploy the tyk-dev-portal Helm chart using the `helm` package from Pulumi const tykDevPortalChart = new helm.v3.Chart('tyk-dev-portal', { chart: "tyk-headless", // The name of the chart in the repository version: "0.9.0", // Desired chart version namespace: "default", // Kubernetes namespace to deploy into fetchOpts: { repo: "http://helm.tyk.io/public/helm/charts/", // Repository URL }, // Specify values for the Helm chart as needed values: { // Values corresponding to tyk-dev-portal configuration // Replace these with actual configuration values }, }, { dependsOn: [catalog] }); // Ensure the catalog is added before deploying the chart // Export the base URL of tyk-dev-portal export const tykDevPortalUrl = `http://tyk-dev-portal.${tykDevPortalChart.namespace}.svc.cluster.local`;
This Pulumi program broadly does the following:
-
Step 1: Declares a cluster ID to specify the target Rancher-managed Kubernetes cluster where you intend to deploy the Tyk Developer Portal.
-
Step 2: Adds the Tyk Helm chart repository as a Rancher catalog. This step is crucial because it tells Rancher where to find the Tyk Helm charts.
-
Step 3: Uses the
helm.v3.Chart
resource to deploy the Tyk Developer Portal to your cluster. This code assumes that you're deploying the "tyk-headless" chart, which should correspond to the Tyk Developer Portal. You should replace0.9.0
with the actual chart version you want to deploy. -
Values: The
values
property in the Helm chart deployment allows you to configure the Tyk Developer Portal chart according to your needs. You should provide the required values conforming to the chart'svalues.yaml
file.
Lastly, the
tykDevPortalUrl
is exported to give you a base URL to access the Tyk Developer Portal once it's deployed. You'll need to replacehttp://tyk-dev-portal.${tykDevPortalChart.namespace}.svc.cluster.local
with the actual URL based on your environment configuration.Please note, this code assumes that you have already set up authentication with your Rancher cluster and Pulumi. If not, you'll need to configure Pulumi to interact with the Rancher provider, and you will need sufficient permissions to add catalogs and deploy charts to the cluster.
-