Deploy the nsp-prometheus-exporter helm chart on AWS EKS
TypeScriptTo deploy the
nsp-prometheus-exporter
helm chart on AWS EKS using Pulumi, you need to follow these steps:- Set up an EKS cluster on AWS.
- Install the
nsp-prometheus-exporter
helm chart onto the cluster.
Firstly, we will create the EKS cluster. We will be using the
@pulumi/eks
package as it provides higher-level abstractions for creating and managing an EKS cluster. This abstracts away some of the complexities and boilerplate code that might otherwise be necessary.Once we have the cluster up and running, we will then use the
@pulumi/kubernetes
package to deploy the helm chart. The helm chart will be installed into the Kubernetes cluster that we created in the first step.Below is the Pulumi program written in TypeScript that performs these two operations:
import * as pulumi from '@pulumi/pulumi'; import * as aws from '@pulumi/aws'; import * as eks from '@pulumi/eks'; import * as k8s from '@pulumi/kubernetes'; // Create an EKS cluster const cluster = new eks.Cluster('my-cluster', { // Specify the desired version for the Kubernetes master and nodes version: '1.21', // Define the node group configuration nodeGroupOptions: { desiredCapacity: 2, // Specify how many nodes you want in your node group minSize: 1, maxSize: 3, }, }); // Export the cluster's kubeconfig export const kubeconfig = cluster.kubeconfig; // Use the cluster's kubeconfig to deploy the helm chart const nsPrometheusExporterChart = new k8s.helm.v3.Chart('nsp-prometheus-exporter', { chart: 'nsp-prometheus-exporter', // The name of the chart to deploy // Specify the chart repository if it's not a stable Helm chart fetchOpts: { repo: 'http://<helm-chart-repository-url>', // Replace with the actual chart repository URL }, // Optionally customize the Helm chart values values: {}, }, { provider: cluster.provider }); // At this point, you've deployed the 'nsp-prometheus-exporter' helm chart on AWS EKS.
In this program, we do the following:
- Import necessary Pulumi packages for AWS, Kubernetes, and EKS.
- Define an EKS cluster named
'my-cluster'
with the desired Kubernetes version (1.21
as an example) and node group configuration. - We export the kubeconfig which will be used later on to communicate with the Kubernetes cluster.
- Deploy the
nsp-prometheus-exporter
helm chart into our EKS cluster. - Note that you will need to replace
'http://<helm-chart-repository-url>'
with the actual URL of the Helm chart's repository.
This program assumes that the
nsp-prometheus-exporter
helm chart is available in a Helm chart repository and that you have the URL for it. If the chart is part of the official Helm chart repository, thefetchOpts
part where the repository is specified can be omitted.Once you set up this Pulumi program, you should run it using the Pulumi CLI:
- Save the code into a file (e.g.,
index.ts
). - Run
pulumi up
from within the directory that contains your file to deploy the cluster and the helm chart.
Review the proposed changes and if you're satisfied, confirm the deployment. Pulumi will provision the EKS cluster and deploy the Helm chart, and once finished, you can use the outputted kubeconfig to interact with your Kubernetes cluster using kubectl.