1. Deploy the prometheus-exporter helm chart on AWS EKS


    To deploy the Prometheus-Exporter Helm chart on an AWS EKS cluster using Pulumi, you'll follow these steps:

    1. Set up an EKS cluster: You'll need an Elastic Kubernetes Service (EKS) cluster running in your AWS environment. If you don't already have one, we will create it using Pulumi's EKS package.

    2. Deploy the Helm chart: Once you have the EKS cluster, you can deploy Helm charts using Pulumi's Kubernetes package. In this case, you will deploy the prometheus-exporter Helm chart.

    Now, let's get to the detailed Pulumi TypeScript program:

    First, you will need to install the necessary Pulumi and Kubernetes packages. You can do this with the following commands:

    npm install @pulumi/pulumi @pulumi/awsx @pulumi/eks @pulumi/kubernetes

    Here is the program that sets up the EKS cluster and deploys the prometheus-exporter Helm chart:

    import * as eks from "@pulumi/eks"; import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster. const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, minSize: 1, maxSize: 3, storageClasses: "gp2", deployDashboard: false // Additional configuration for the EKS cluster if needed. }); // Once the cluster is created, we can deploy the Prometheus-Exporter Helm chart into the EKS cluster. // First, you need to create a provider for the created cluster so Pulumi can communicate with the cluster. const provider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify) }); // Deploying the Prometheus-Exporter Helm chart using the k8s provider. const prometheusExporterChart = new k8s.helm.v3.Chart("prometheus-exporter", { chart: "prometheus-exporter", version: "x.x.x", // Replace this with the version of the chart you want to deploy. namespace: "monitoring", // Specify a namespace or use the default one. fetchOpts: { repo: "https://prometheus-community.github.io/helm-charts" // Replace this with the repository where the chart is stored if different. }, }, { provider: provider }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Export the Prometheus-Exporter service URL, if it is a LoadBalancer Service. export const prometheusExporterServiceUrl = prometheusExporterChart .getResourceProperty("v1/Service", "monitoring", "prometheus-exporter-service", "status") .apply(status => status.loadBalancer.ingress[0].hostname || status.loadBalancer.ingress[0].ip);

    Don't forget to replace "x.x.x" with the actual version of the Prometheus-Exporter Helm chart you wish to deploy.


    • eks.Cluster: This class creates an EKS cluster. You specify the cluster's size and other configurations here.
    • k8s.Provider: This Kubernetes provider uses the kubeconfig generated by the EKS cluster to interact with it.
    • k8s.helm.v3.Chart: This is used to deploy the Helm chart onto your cluster. You specify the chart name, version, and its repository URL.

    You'll also notice the usage of the .apply method. This is part of Pulumi's programming model and allows us to handle outputs that are only known at runtime, in this case, the kubeconfig and status of the Prometheus-Exporter Service.

    To apply this Pulumi program:

    1. Save this code in a file named index.ts.
    2. Ensure you are authenticated with AWS and have the Pulumi CLI installed.
    3. Run pulumi up to preview and deploy the changes.

    Remember, when running pulumi up, you might incur AWS costs after the resources are provisioned.

    The kubeconfig is exported so that you can use it with kubectl to interact with your EKS cluster. Similarly, if your Prometheus-Exporter chart exposes a LoadBalancer service, the URL for that service is also exported as prometheusExporterServiceUrl.