Deploy the heartbeat helm chart on AWS EKS
TypeScriptTo deploy the Heartbeat Helm chart on an AWS EKS cluster, you’ll first need to set up an EKS cluster. Once the cluster is running, you can deploy Heartbeat, which is an Elastic Stack tool for monitoring service uptime, using a Helm chart.
The following steps outline the process we’ll go through:
- Create an EKS cluster: Set up an EKS cluster using Pulumi’s EKS package, which simplifies the process.
- Deploy the Heartbeat Helm chart: Once the cluster is running, we'll use Pulumi's Kubernetes package to deploy the Heartbeat Helm chart onto that EKS cluster.
Here's a detailed Pulumi program written in TypeScript to accomplish this:
import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an AWS EKS Cluster // We're creating an EKS cluster with the default configuration, which includes // managed node groups and default VPC. const cluster = new eks.Cluster("heartbeat-cluster", {}); // Step 2: Deploy the Heartbeat Helm Chart // Once the cluster is provisioned, the kubeconfig is obtained from the cluster // to interact with the Kubernetes cluster and deploy applications. // We'll use the Helm chart for Heartbeat provided by Elastic, which needs to // be added as a repository before installation. // Configure the Kubernetes provider to use the kubeconfig from the generated EKS cluster const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Add the Elastic Helm chart repository const elasticRepo = new k8s.helm.v3.Repository("elastic-repo", { name: "elastic", url: "https://helm.elastic.co", }, { provider: k8sProvider }); // Deploy the Heartbeat Helm chart from the Elastic repository const heartbeatChart = new k8s.helm.v3.Chart("heartbeat", { chart: "heartbeat", version: "7.10.0", // Specify the exact chart version namespace: "monitoring", fetchOpts: { repo: "https://helm.elastic.co", }, // Configuration options for the Heartbeat chart can be added here values: { // Add your configuration } }, { provider: k8sProvider, dependsOn: [elasticRepo] }); // Export the cluster's kubeconfig export const kubeconfig = cluster.kubeconfig;
Here is an explanation of what each part of this program does:
- EKS Cluster Creation:
eks.Cluster
is used to create a cluster in AWS Elastic Kubernetes Service. This is the environment where your Kubernetes applications will run. - Kubernetes Provider Configuration:
k8s.Provider
is the Pulumi object to interact with the Kubernetes cluster. We are passing thekubeconfig
from the newly created EKS cluster to it. - Helm Chart Repository: Using
k8s.helm.v3.Repository
we add the Elastic Helm repository which houses the Heartbeat Helm chart. - Heartbeat Helm Chart Deployment: We deploy Heartbeat using
k8s.helm.v3.Chart
, referencing the chart and specifying the version.
The
values
object in the Helm chart deployment can be filled with specific Heartbeat configuration parameters as per your requirements.To run this Pulumi program, you should have Pulumi CLI installed and AWS credentials configured on your machine. After these resources have been defined in your TypeScript program, run
pulumi up
to create the resources in your AWS account.One thing to note is that you should also have Helm installed if you need to fetch or manage Helm charts locally, and
kubectl
for communication with your Kubernetes cluster, although Pulumi can abstract most of these interactions.After the deployment, you can use the exported
kubeconfig
to connect to your Kubernetes cluster usingkubectl
or any Kubernetes client, and manage your Heartbeat deployment directly if needed.