Deploy the elasticsearch-master helm chart on AWS EKS
TypeScriptTo deploy the
elasticsearch-master
Helm chart on an AWS EKS cluster using Pulumi, you'll need to perform several steps:- Create an EKS cluster.
- Deploy the Helm chart onto the cluster.
First, you'll need to install the necessary Pulumi packages for AWS and Kubernetes, which include
@pulumi/aws
,@pulumi/eks
, and@pulumi/kubernetes
. You can install these usingnpm
oryarn
with the respective commandnpm install @pulumi/aws @pulumi/eks @pulumi/kubernetes
oryarn add @pulumi/aws @pulumi/eks @pulumi/kubernetes
.Here is a TypeScript program that performs both steps:
import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as aws from "@pulumi/aws"; // Create an EKS cluster. const cluster = new eks.Cluster("my-cluster", { // Define the properties for the EKS cluster as desired. // This example uses default configurations // for simplicity, consult the eks.Cluster documentation for detailed options. }); // Once the cluster is created, we can use a k8s.Provider to interact with it. const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Now we can deploy the elasticsearch-master Helm chart onto our cluster. const elasticsearchChart = new k8s.helm.v3.Chart("elasticsearch-master", { chart: "elasticsearch", version: "7.9.3", // Specify the chart version you wish to deploy fetchOpts: { repo: "https://helm.elastic.co", }, }, { provider: k8sProvider }); // Export the cluster's kubeconfig and the Helm chart's status. export const kubeconfig = cluster.kubeconfig; export const elasticsearchStatus = elasticsearchChart.status;
Let's break this down:
-
We start by creating an EKS cluster with
eks.Cluster
. This component creates an EKS cluster with default settings. In a production environment, you'd likely want to configure additional settings, such as IAM roles, VPC configuration, and the desired node count and types. Please refer to the eks.Cluster documentation for detailed information on the configurable properties. -
Once the cluster is up, we instantiate a
k8s.Provider
which is required to deploy Kubernetes resources onto the cluster. This provider uses the kubeconfig that is output from our EKS cluster. -
With the provider configured, we define a Helm chart resource using
k8s.helm.v3.Chart
. By specifying the chart name,elasticsearch
, we instruct Pulumi to deploy theelasticsearch-master
Helm chart. ThefetchOpts
property is where we specify the Helm repository. Again, you might need to adjust theversion
to the one you intend to deploy. -
Lastly, we export the
kubeconfig
which you can use to interact with your EKS cluster usingkubectl
and other Kubernetes tools, as well as the status of the Helm chart release, which can help in understanding whether the deployment was successful and in debugging if there are issues.
After writing your TypeScript file (let's say
index.ts
), you can deploy this stack using Pulumi CLI commands likepulumi up
. Ensure your AWS credentials are configured correctly, as Pulumi will use them to provision resources on your behalf on AWS.