Deploy the benthos helm chart on AWS EKS
TypeScriptTo deploy the Benthos Helm chart on AWS Elastic Kubernetes Service (EKS), we'll walk through these steps:
- Create an EKS cluster, which is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS without needing to install and operate your own Kubernetes control plane or worker nodes.
- Deploy the Benthos Helm chart to the EKS cluster. Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes applications.
For the EKS cluster creation, we'll use the
eks.Cluster
resource, which simplifies the process of creating an EKS cluster.Once the cluster is running, we can use Helm to deploy Benthos. For deploying Helm charts, we'll use the
helm.v3.Chart
resource.Here's a complete TypeScript program that uses Pulumi to create an AWS EKS cluster and deploys the Benthos Helm chart:
import * as eks from "@pulumi/eks"; import * as pulumi from "@pulumi/pulumi"; import * as helm from "@pulumi/kubernetes/helm"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster. const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, minSize: 1, maxSize: 2, instanceType: "t2.medium", providerCredentialOpts: { profileName: "aws-profile", // Ensure your AWS profile is configured with the right permissions }, }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses our EKS cluster from above. const k8sProvider = new k8s.Provider("eks-k8s", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy Benthos Helm chart using the k8s provider for our cluster. const benthosChart = new helm.v3.Chart("benthos", { chart: "benthos", fetchOpts:{ repo: "https://github.com/benthosdev/helm-charts.git", // Replace with the correct Helm chart repository URL for Benthos }, version: "1.0.0", // Specify the version of Benthos Helm chart you wish to deploy }, { provider: k8sProvider }); // Export the Benthos service endpoint export const benthosService = pulumi.interpolate `${benthosChart.getResourceProperty("v1/Service", "benthos", "status").apply(status => status.loadBalancer.ingress[0].hostname || status.loadBalancer.ingress[0].ip)}`;
Explanation of the code:
-
The
eks.Cluster
resource provisions a new EKS cluster. You can adjust properties such asdesiredCapacity
,minSize
, andmaxSize
to configure the size of your cluster and theinstanceType
to specify the type of EC2 instances for your worker nodes. -
We export the
kubeconfig
output of the cluster so that you can interact with your Kubernetes cluster usingkubectl
or any Kubernetes-compatible tool. -
A Kubernetes
Provider
is instantiated with our EKS cluster's kubeconfig. This provider is used to interact with our EKS cluster, which is necessary for deploying Helm charts onto the cluster. -
The
helm.v3.Chart
resource deploys the Benthos Helm chart to our cluster. You should provide the exact repository URL where the Benthos Helm chart is hosted. -
Finally, we export
benthosService
which gets the externally accessible endpoint of the Benthos service so you can interact with it.
Make sure to replace any placeholders with your specific details, such as the AWS profile, Benthos Helm chart version, and repository URL if they are different from what is listed above.
Before running this Pulumi program, you should have Pulumi CLI installed, an AWS account configured, and your AWS credentials set up. After writing the code into a file (e.g.,
index.ts
), you can execute the program by runningpulumi up
in the CLI, which will provision the resources defined in the code.