Deploy the kubescape-relevancy helm chart on AWS EKS
TypeScriptTo deploy the
kubescape-relevancy
Helm chart on an AWS EKS cluster using Pulumi, you'll need to follow these steps:- Set Up the EKS Cluster: We'll use the
eks.Cluster
resource to provision an EKS cluster on AWS. - Deploy the Helm Chart: We'll use the
kubernetes.helm.sh/v3.Chart
resource to deploy the Helm chart on the provisioned EKS cluster.
Here's how you can accomplish this with a Pulumi program written in TypeScript:
Detailed Explanation
Before we start writing actual code, ensure that you have the following prerequisites in place:
- Install Pulumi CLI
- Configure AWS credentials for Pulumi
- Install Node.js and TypeScript
- Set up an EKS-compatible IAM role and VPC if you wish to use existing ones. Otherwise, Pulumi will create these for you with default settings.
The following program will:
- Create a VPC configured for an EKS cluster (if an existing VPC is not provided).
- Provision an EKS cluster using the
eks.Cluster
resource from Pulumi's EKS package. - Deploy the specified Helm chart
kubescape-relevancy
to the EKS cluster usingkubernetes.helm.sh/v3.Chart
.
Pulumi Program
import * as eks from '@pulumi/eks'; import * as k8s from '@pulumi/kubernetes'; // Create an EKS cluster const cluster = new eks.Cluster('my-cluster', { instanceType: "t2.medium", desiredCapacity: 2, minSize: 1, maxSize: 3, storageClasses: "gp2", deployDashboard: false, }); // Export the clusters' kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes Provider using the generated kubeconfig. const provider = new k8s.Provider('k8s-provider', { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy the 'kubescape-relevancy' Helm chart const chart = new k8s.helm.v3.Chart('kubescape-relevancy-chart', { chart: 'kubescape-relevancy', // Add Chart repository URL here if it's a custom or external Helm chart. // e.g., 'repo': 'http://my-chart-repo/', values: {}, // Provide any custom values here // You may specify the version of the chart to deploy. // e.g., 'version': '1.2.3', }, { provider }); // Exports export const eksClusterName = cluster.eksCluster.name; export const kubeconfigOutput = kubeconfig;
This program starts by importing the necessary Pulumi packages for AWS EKS and Kubernetes.
We create an EKS cluster (
my-cluster
) with some initial settings for the EC2 instance type and autoscaling group configuration. If you have a specific IAM role or VPC that you wish to use, you can specify them as arguments to theeks.Cluster
resource.Once the cluster is provisioned, we export its kubeconfig, which is necessary to communicate with the cluster using
kubectl
and other Kubernetes tools.Next, we create a Pulumi Kubernetes provider associated with our EKS cluster. We use the kubeconfig of our EKS cluster to authorize this provider.
Following that, we define a Helm chart resource,
kubescape-relevancy-chart
, using thekubernetes.helm.sh/v3.Chart
resource type. You need to specify the chart name, optionally the repository URL if the chart is not on a publicly accessible Helm repository, and any custom values you want to apply to the chart. If the chart requires a specific version, that can be specified in theversion
parameter.After deploying this program with Pulumi, you should have a running EKS cluster with the
kubescape-relevancy
Helm chart deployed.Keep in mind that the
kubescape-relevancy
chart name is used as a placeholder. Replace it with the actual name of the chart you wish to deploy, and provide the chart repository URL if it's not a standard Helm chart available in the public Helm repository.Please consult the Pulumi documentation linked in the code comments for more details on the resources used:
- Set Up the EKS Cluster: We'll use the