1. Deploy the simple-mongodb helm chart on AWS EKS


    To deploy the simple-mongodb Helm chart on an AWS Elastic Kubernetes Service (EKS) cluster using Pulumi, you'll proceed with the following steps:

    1. Set up an EKS cluster: You'll create an EKS cluster, which forms the Kubernetes environment within AWS.
    2. Install the Helm chart: Once your cluster is up and operational, you'll deploy the simple-mongodb Helm chart to it.

    For this process, we'll be using the @pulumi/eks module to create the EKS cluster and the @pulumi/kubernetes module to deploy the Helm chart. The @pulumi/eks package provides a higher-level abstraction over AWS resources, specifically for creating and managing EKS clusters, whereas @pulumi/kubernetes provides the functionality to work with Kubernetes resources, including managing Helm charts.

    Below is the Pulumi program in TypeScript to accomplish these tasks:

    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", { // You can specify additional options here. For example, you might want to define: // - VPC configuration // - Desired and max instance count for the auto-scaling group (here we are accepting the defaults) // - The instance types for the worker nodes // - IAM role for the EKS cluster // - Enable public and private access endpoints // As these come with sensible defaults, they are omitted here for brevity. }); // Once the cluster is created, you can deploy the `simple-mongodb` Helm chart to it. // The `k8s.Provider` is used to supply the configuration needed for Pulumi to communicate with the // Kubernetes cluster. Here we pass in the Kubeconfig from the generated EKS cluster. const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy the `simple-mongodb` Helm chart into the EKS cluster. Make sure that you have the correct // repository and chart name. This is a placeholder and might be different. const mongoDbChart = new k8s.helm.v3.Chart("simple-mongodb", { chart: "mongodb", version: "10.28.4", // Replace with the appropriate chart version. fetchOpts: { repo: "https://charts.bitnami.com/bitnami", // The repository URL where the chart is located. }, // You can define additional Helm values here. For example, if you need to specify custom // configuration parameters or resource requirements. }, { provider: k8sProvider }); // Export the cluster's kubeconfig to connect to your cluster using kubectl. export const kubeconfig = pulumi.secret(cluster.kubeconfig); // Export the MongoDB service endpoint, for example, to connect to your database. export const mongoDbEndpoint = mongoDbChart.getResourceProperty("v1/Service", "simple-mongodb", "status").apply(status => status.loadBalancer.ingress[0].ip);

    In this program:

    • We create an instance of eks.Cluster which encapsulates the AWS EKS cluster.
    • The k8s.Provider instance is initialized with the kubeconfig from our EKS cluster, allowing Pulumi to subsequently create resources in that cluster.
    • We then use the k8s.helm.v3.Chart to install the mongodb chart from Bitnami's chart repository. This assumes that you want to deploy MongoDB from the Bitnami repo – please replace with the simple-mongodb chart details if it's different.

    This program can then be deployed using the Pulumi CLI, which will handle provisioning the AWS resources and deploying the Helm chart.


    • Ensure you have the necessary prerequisites installed, including Pulumi, AWS CLI, and configured AWS access.
    • Replace chart and version with the appropriate values for the simple-mongodb chart you want to deploy. The repo should be the URL where your chart is hosted; in this case, the URL provided points to Bitnami's repo.
    • Make sure to replace the getResourceProperty part of mongoDbEndpoint export with the correct resource references based on your chart.
    • If your chart requires custom values, you can provide them in the values field within the Chart resource.
    • In the exported mongoDbEndpoint, .apply is used to obtain the MongoDB service's IP address after deployment, which may vary based on your chart's details and whether you're using LoadBalancer or ClusterIP services.
    • You might need to provide additional IAM roles or policies depending on your AWS setup and what your EKS cluster needs to access.