1. Deploy the opendistro-es helm chart on AWS EKS

    TypeScript

    To deploy the Open Distro for Elasticsearch (opendistro-es) Helm chart on an AWS Elastic Kubernetes Service (EKS) cluster using Pulumi, you’ll perform several steps. These include setting up an EKS cluster if you don't already have one, installing the Helm chart into the cluster, and configuring access to the Elasticsearch cluster.

    Below is a detailed program written in TypeScript that will do the following:

    1. Create an EKS Cluster: Using @pulumi/eks module, it will set up an EKS cluster. This simplifies the creation and configuration of an EKS cluster compared to using lower-level resources directly from the @pulumi/aws module.

    2. Deploy the opendistro-es Helm Chart: Once the cluster is created, we'll use the @pulumi/kubernetes module to deploy the Helm chart on it.

    Here is the Pulumi TypeScript program that will accomplish these tasks:

    import * as eks from '@pulumi/eks'; import * as pulumi from '@pulumi/pulumi'; import * as k8s from '@pulumi/kubernetes'; // Step 1: Create an EKS cluster const cluster = new eks.Cluster('opendistro-es-cluster', { // Define the size and number of nodes you want in your cluster desiredCapacity: 2, minSize: 1, maxSize: 3, // Specify the instance type for the nodes instanceType: 't2.medium', // IAM role for the nodes, if you have a specific IAM role to attach // instanceRole: instanceRole, }); // Export the cluster's kubeconfig export const kubeconfig = cluster.kubeconfig; // Step 2: Deploy the opendistro-es Helm chart on the EKS cluster // First, create a new K8s provider instance using the kubeconfig from the EKS cluster const k8sProvider = new k8s.Provider('k8s-provider', { kubeconfig: kubeconfig.apply(JSON.stringify), }); // Then, use the Helm Chart resource to deploy opendistro-es const opendistroESChart = new k8s.helm.v3.Chart('opendistro-es', { chart: 'opendistro-es', version: '1.13.2', // Specify the exact chart version you need fetchOpts: { repo: 'https://opendistro.github.io/for-elasticsearch-docs/', }, // Define values from the opendistro-es Helm chart's 'values.yaml' or custom values you need values: { elasticsearch: { rest: { enabled: true, }, }, }, }, { provider: k8sProvider }); // Export the Helm chart resources export const opendistroHelmResources = opendistroESChart.resources;

    Explanation:

    • EKS Cluster: The eks.Cluster resource creates a new EKS cluster with default settings for node size, number of nodes, and instance type. You can adjust these settings to fit your workload. The desiredCapacity, minSize, and maxSize parameters control the scaling behavior of your node group.

    • Kubernetes Provider: The k8s.Provider is configured with the kubeconfig from the EKS cluster which allows Pulumi to communicate with your newly created EKS cluster.

    • Helm Chart: The k8s.helm.v3.Chart resource is used to deploy the Open Distro for Elasticsearch Helm chart into your cluster. You can modify the values field to configure Elasticsearch to your needs. The version field is used to pin the chart to a specific version.

    • Exports: The program exports the kubeconfig and Helm chart resources. With kubeconfig, you can interact with your cluster using kubectl or other Kubernetes tools. The opendistroHelmResources export shows you the deployed Helm resources within your cluster.

    Prerequisites:

    • Make sure you have Pulumi CLI installed.
    • Configure your AWS credentials so that Pulumi can deploy resources to your AWS account.
    • Replace the version value in the opendistro-es chart with the version you want to install.

    After you copy the program into a Pulumi project, you can deploy the cluster and Open Distro for Elasticsearch by running pulumi up from the command line within the project directory.