Deploy the elasticsearch-agent helm chart on AWS EKS
TypeScriptTo deploy the elasticsearch-agent Helm chart on AWS EKS, you will need to follow these steps:
-
Set up an Amazon EKS Cluster: This will be the Kubernetes cluster where your Elasticsearch Agent will run.
-
Configure and Deploy the Helm Chart: Helm Charts are packages that contain pre-configured Kubernetes resources. You will deploy the
elasticsearch-agent
Helm chart into your EKS cluster.
Below is a Pulumi TypeScript program that completes these steps:
import * as eks from "@pulumi/eks"; import * as aws from "@pulumi/aws"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster with the default configuration. const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, minSize: 1, maxSize: 2, storageClasses: "gp2", deployDashboard: false, }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses our cluster from above. const provider = new k8s.Provider("provider", { kubeconfig: cluster.kubeconfig, }); // Deploy the elasticsearch-agent helm chart into the cluster we created. const elasticsearchAgentChart = new k8s.helm.v3.Chart( "elasticsearch-agent", { chart: "elasticsearch", version: "7.14.0", // specify the version you wish to deploy fetchOpts:{ repo: "https://helm.elastic.co", }, // Values from the Helm chart's values.yaml can be provided here. values: { // ... specify your configuration here }, }, { provider: provider }, ); // Export the resources created by the Helm chart that might be needed. export const chartResources = elasticsearchAgentChart.resources;
Detailed Explanation:
-
EKS Cluster: The program begins by using the
@pulumi/eks
module to create an EKS cluster. ThedesiredCapacity
,minSize
, andmaxSize
are configurations for the node group in the cluster, defining a minimum and maximum number of worker nodes. -
Kubeconfig Export: It exports the kubeconfig needed to interact with the cluster using
kubectl
or other Kubernetes tooling. -
Provider Creation: A Pulumi Kubernetes provider is initialized with the kubeconfig. This provider is used to deploy resources to the EKS cluster we created.
-
Helm Chart Deployment: The
@pulumi/kubernetes
module is used to deploy theelasticsearch-agent
Helm chart to the cluster. This step assumes thatelasticsearch-agent
refers to a Helm chart available in the specified Helm repository. You might need to adjust thechart
andversion
to match the elasticsearch-agent chart you want to deploy. -
Resource Exports: Finally, the program exports the resources created by the Helm chart deployment. This allows you to see details of the Kubernetes resources that were created as a result of the Helm chart deployment.
To use this Pulumi program, make sure you have Pulumi installed and configured with AWS credentials. Save the code to a file named
index.ts
in a new Pulumi project directory, then runpulumi up
to create the resources. After confirming the resources to be created, Pulumi will go ahead and provision them in your AWS account.-