Deploy the tenant-insights helm chart on AWS EKS
TypeScriptTo deploy the
tenant-insights
Helm chart on AWS EKS, you'll need to complete a few steps:- Create an EKS Cluster: You'll need an EKS cluster where your Helm chart can be deployed. This involves setting up the cluster itself along with the necessary IAM roles and VPC configuration.
- Install Helm on your Local System: Helm is a package manager for Kubernetes, which you'll use to deploy the
tenant-insights
Helm chart to your cluster. - Deploy the Helm Chart: Once you have your cluster and Helm ready, you can deploy your chart to the EKS cluster.
Here is how you can set up an EKS cluster and deploy the chart with Pulumi:
import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an EKS Cluster. // We are creating a new VPC and EKS cluster specifically for your Helm chart. const vpc = new awsx.ec2.Vpc("tenantInsightsVpc", { numberOfAvailabilityZones: 2, // Define how many availability zones you want your VPC to cover. }); const role = new aws.iam.Role("eks-cluster-role", { assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "eks.amazonaws.com" }), }); const cluster = new eks.Cluster("tenantInsightsCluster", { vpcId: vpc.id, subnetIds: vpc.publicSubnetIds, instanceType: "t2.medium", desiredCapacity: 2, // Set the desired number of cluster nodes. minSize: 1, maxSize: 3, roleMappings: [{ groups: ["system:masters"], roleArn: role.arn, username: "admin", }], // You can add additional configuration such as versions, tags, etc. }); // Step 2: Install Helm chart. // This assumes you have Helm installed on your system and the `tenant-insights` chart available in a chart repository. // Create a Kubernetes provider instance using the kubeconfig obtained from the EKS cluster. const provider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy the Helm chart to the cluster. const tenantInsightsChart = new k8s.helm.v3.Chart("tenantInsights", { chart: "tenant-insights", fetchOpts: { repo: "https://charts.example.com/", // Replace with the actual Helm chart repository URL. }, values: { // Define any values needed for the Helm chart. }, }, { provider }); // Export the cluster's kubeconfig and the endpoint to access the deployed Helm chart's application. export const kubeconfig = cluster.kubeconfig; export const applicationEndpoint = tenantInsightsChart.getResourceProperty("v1/Service", "tenant-insights", "status");
Explanation:
-
Create EKS Cluster: We use the
@pulumi/eks
provider to set up an EKS cluster inside a new VPC. We configure the cluster with the desired number of nodes and the instance type that will run the Kubernetes workloads. -
EKS IAM Role: We create an AWS IAM role for the EKS cluster so that it has the necessary AWS permissions to operate.
-
Kubernetes Provider: Using the
@pulumi/kubernetes
package, we create a Kubernetes provider. This provider is used by Pulumi to interact with the EKS cluster we created. We pass the kubeconfig from the EKS cluster to this provider so that it knows how to communicate with our cluster. -
Deploy Helm Chart: Next, we create a
Chart
resource which tells Pulumi to deploy a Helm chart. We specify the name of the chart, the repository where it can be found, and any values we want to override. -
Output Kubeconfig and Endpoint: Finally, we export the kubeconfig of our EKS cluster and the endpoint for our deployed application. These can be used to interact with the cluster and the application running on it.
For the URL in the
fetchOpts
for the Helm chart, you need to replace"https://charts.example.com/"
with the actual repository where thetenant-insights
chart is hosted.Keep in mind that deploying infrastructure with Pulumi by default requires you to login to a Pulumi account to manage the state of your resources. If you'd rather manage your state locally, or on your self-hosted backend, you can use the
pulumi login --local
command, or other backend options available with Pulumi.