1. Deploy the generic-secrets helm chart on AWS EKS


    Deploying a Helm chart on an AWS Elastic Kubernetes Service (EKS) cluster involves several steps. You will first need an EKS cluster up and running. This program will demonstrate how to create an EKS cluster and deploy a Helm chart for generic-secrets using Pulumi with TypeScript.

    Before starting with the Pulumi program, ensure you have the following prerequisites:

    1. Pulumi CLI installed and configured with your AWS account.
    2. AWS CLI installed and configured with your AWS account.
    3. Kubernetes CLI (kubectl) installed to interact with the EKS cluster.
    4. Helm CLI (helm) installed to manage Helm charts.

    The following Pulumi program performs two key actions:

    1. Sets up an EKS cluster by using the @pulumi/eks package, which simplifies the creation of EKS clusters.
    2. Deploys a Helm chart to the EKS cluster using the @pulumi/kubernetes package. In this case, we will simulate the deployment of a generic-secrets chart by deploying an example chart named nginx.

    Let's start by creating the EKS cluster and then deploying the Helm chart to it.

    import * as eks from "@pulumi/eks"; 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, }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses our EKS cluster. const provider = new k8s.Provider("provider", { kubeconfig: cluster.kubeconfig, }); // Deploy the `generic-secrets` helm chart. const genericSecretsChart = new k8s.helm.v3.Chart("generic-secrets", { chart: "nginx", // This is an example. You should use the actual chart for `generic-secrets`. version: "1.17.10", // Specify the chart version you want to deploy. fetchOpts: { repo: "https://charts.helm.sh/stable", // Replace with the actual Helm repo URL for `generic-secrets`. }, }, { provider }); // Ensure that the Helm chart is deployed using the EKS cluster's kubeconfig. // Export the deployment name of the Helm chart. export const helmDeploymentName = genericSecretsChart.getResourceName("v1/Service", "generic-secrets");

    Here is what each part of this program does:

    1. The eks.Cluster resource represents an EKS cluster. The desiredCapacity, minSize, and maxSize are configurations for the cluster's node group that dictate the scaling properties. You can adjust these properties based on your requirements.

    2. The kubeconfig export allows you to use your EKS cluster outside of Pulumi, with tools such as kubectl.

    3. A k8s.Provider is created, representing the ability to deploy resources into the Kubernetes cluster we have created. It uses the kubeconfig from the EKS cluster so that it can communicate with it.

    4. The k8s.helm.v3.Chart resource is used to deploy Helm charts. Here, for demonstration purposes, the program uses the nginx chart as an example since the actual chart for generic-secrets is not specified. Replace "nginx" with the name of the chart you want to deploy and the repo field with the repository that houses the generic-secrets chart.

    To execute this Pulumi program, save it to a index.ts file, and then run the following commands in your terminal:

    pulumi up

    This will prompt Pulumi to provision the AWS EKS cluster and deploy the Helm chart as defined. Once deployed, kubeconfig and helmDeploymentName will be outputted, which you can use to interact with your EKS cluster and deployed Helm chart.

    Please replace "nginx" and the respective version number and repository with the actual chart details of generic-secrets that you wish to install on your cluster.