1. Using kubernetes elasticsearch.k8s.elastic.co with enterprise.gloo.solo.io

    TypeScript

    To use Elasticsearch Kubernetes Operator (elasticsearch.k8s.elastic.co) along with Gloo Enterprise API Gateway (enterprise.gloo.solo.io) in a Kubernetes cluster with Pulumi, we will follow these steps:

    1. Set up a Kubernetes cluster.
    2. Install the Elasticsearch operator.
    3. Create an Elasticsearch cluster using the operator.
    4. Install Gloo Enterprise on the Kubernetes cluster.
    5. Configure Gloo to work with the Elasticsearch cluster.

    For the purpose of this program, we will assume you have already configured Pulumi to connect to your Kubernetes cluster. Now let's dive into the details of each step.

    Step 1: Set up a Kubernetes cluster

    We will start by provisioning a Kubernetes cluster. For this example, we will use AWS Elastic Kubernetes Service (EKS) to create the cluster. To provide the cluster, we will use the eks.Cluster resource from the @pulumi/eks package.

    Step 2: Install the Elasticsearch operator

    With the Kubernetes cluster set up, we will install the Elasticsearch operator, which manages Elasticsearch clusters within a Kubernetes cluster. This operator is not directly available in the Pulumi libraries, so we will install it using a ConfigFile resource from the @pulumi/kubernetes package, assuming the operator's manifests are available in a YAML file locally or hosted online.

    Step 3: Create an Elasticsearch cluster

    Once the Elasticsearch operator is installed, we will create an ElasticSearch cluster by defining the custom resource that the operator provides. This custom resource is defined using CustomResource from the @pulumi/kubernetes package.

    Step 4: Install Gloo Enterprise

    For the API Gateway, we will install Gloo Enterprise using its Helm chart with the Chart resource from the @pulumi/kubernetes/helm/v3 package.

    Step 5: Configure Gloo to work with Elasticsearch

    Finally, we will need to create the relevant Gloo configuration to route to our Elasticsearch service. We will create a VirtualService that directs traffic to the Elasticsearch service.

    Let's put this into a Pulumi program using TypeScript:

    import * as pulumi from "@pulumi/pulumi"; import * as kubernetes from "@pulumi/kubernetes"; import * as eks from "@pulumi/eks"; import * as helm from "@pulumi/kubernetes/helm/v3"; // Step 1: Provision an EKS cluster const clusterName = "pulumi-eks-cluster"; const cluster = new eks.Cluster(clusterName, { instanceType: "t2.medium", desiredCapacity: 2, minSize: 1, maxSize: 3, }); // Kubeconfig to connect to the created cluster const kubeconfig = cluster.kubeconfig.apply(JSON.stringify); // Create a provider to install resources in this cluster const provider = new kubernetes.Provider("provider", { kubeconfig }); // Step 2: Install Elasticsearch operator const elasticsearchOperatorUrl = "https://operator.elastic.co/path/to/elasticsearch-operator.yaml"; const elasticsearchOperator = new kubernetes.yaml.ConfigFile("elasticsearch-operator", { file: elasticsearchOperatorUrl, }, { provider }); // Step 3: Create an Elasticsearch cluster const elasticsearchCluster = new kubernetes.yaml.ConfigFile("elasticsearch-cluster", { file: `apiVersion: elasticsearch.k8s.elastic.co/v1 kind: Elasticsearch metadata: name: elasticsearch spec: version: 7.17.3`, }, { provider, dependsOn: elasticsearchOperator }); // Step 4: Install Gloo Enterprise using Helm const glooChart = new helm.Chart("gloo-ent", { chart: "gloo", version: "1.8.0", fetchOpts: { repo: "https://storage.googleapis.com/gloo-ee-helm" }, values: { gloo: { rbac: { create: true, }, }, license_key: "<your-license-key-here>", }, }, { provider }); // Step 5: Configure Gloo VirtualService to route to Elasticsearch const virtualService = new kubernetes.yaml.ConfigFile("elasticsearch-virtualservice", { file: `apiVersion: enterprise.gloo.solo.io/v1 kind: VirtualService metadata: name: elasticsearch-vs spec: virtualHost: domains: - '*' routes: - matchers: - prefix: '/elasticsearch' routeAction: single: kube: ref: name: elasticsearch namespace: default port: 9200`, }, { provider, dependsOn: [glooChart, elasticsearchCluster] }); // Export the public endpoint of the ElasticSearch service export const elasticsearchEndpoint = pulumi.interpolate`${elasticsearchCluster.getResourceProperty("v1/Service", "elasticsearch", "status")}`;

    This program will set up the EKS Cluster and install both Elasticsearch and Gloo Enterprise. The resources are created in an order that respects the required dependencies, and we export the Elasticsearch service endpoint, which can be used to interact with your Elasticsearch cluster.

    Replace "<your-license-key-here>" in the Gloo chart values with your actual Gloo Enterprise license key.

    This example does not include ElasticSearch data node, master node, or Gloo configuration details for brevity, but you could extend the elasticsearchCluster and virtualService resources according to your desired cluster specifications and Gloo configurations.

    To apply this Pulumi program:

    • Install the Pulumi CLI and set up your AWS credentials.
    • Create a new Pulumi project with pulumi new typescript.
    • Replace the code in index.ts with the above program.
    • Run pulumi up to provision the resources.

    For your actual deployment, make sure to provide the right versions, settings, and configurations as per your requirements.