1. Deploy the keptn-addons helm chart on AWS EKS

    TypeScript

    To deploy the keptn-addons helm chart on an AWS EKS cluster using Pulumi, you'll need to go through the following steps:

    1. Create an EKS Cluster: You'll start by creating an Amazon EKS (Elastic Kubernetes Service) cluster. This will be the Kubernetes cluster where the helm chart will be deployed.

    2. Install Helm and Addons: With the EKS cluster in place, you'll use the Helm package manager to install the keptn-addons. You'll define a Helm release using the Pulumi Kubernetes provider.

    Here's a program written in TypeScript that demonstrates these steps. This program uses the high-level eks package which is a Pulumi ComponentResource that wraps the creation and configuration of an EKS cluster with best practices by default. It then uses the kubernetes package to deploy the helm chart to the EKS cluster.

    Before you can run this program, make sure you have installed the Pulumi CLI, set up your AWS credentials, and configured Pulumi to use them.

    import * as pulumi from '@pulumi/pulumi'; import * as aws from '@pulumi/aws'; import * as eks from '@pulumi/eks'; import * as kubernetes from '@pulumi/kubernetes'; // Create a VPC for our cluster. const vpc = new aws.ec2.Vpc("my-vpc", { cidrBlock: "10.100.0.0/16", }); // Create a subnet for our cluster. const subnet = new aws.ec2.Subnet("my-subnet", { vpcId: vpc.id, cidrBlock: "10.100.0.0/24", availabilityZone: "us-west-2a", }); // Create an EKS cluster with the default configuration. const cluster = new eks.Cluster("my-cluster", { vpcId: vpc.id, subnetIds: [subnet.id], }); // Get the kubeconfig from the EKS cluster to interact with it. const kubeconfig = cluster.kubeconfig.apply(JSON.stringify); // Create a Kubernetes provider instance that uses the EKS cluster's kubeconfig. const k8sProvider = new kubernetes.Provider("k8s-provider", { kubeconfig: kubeconfig, }); // Helm chart installation for keptn-addons const keptnAddonsChart = new kubernetes.helm.v3.Chart("keptn-addons", { chart: "keptn-addons", // The repository where keptn-addons is located. // Replace this with the actual repository if it's different. repo: "https://charts.keptn.sh/", // Assume the namespace "keptn" should host the addons, // change this if you need to deploy in a different namespace. namespace: "keptn", version: "x.y.z", // Replace "x.y.z" with the actual chart version }, { provider: k8sProvider }); // Export the cluster's kubeconfig. export const kubeConfigOutput = kubeconfig;

    Here's an explanation of what the above program does:

    • VPC Creation: We create a new VPC for our cluster. This VPC is where all resources, such as the EKS cluster and any EC2 instances, will live.

    • Subnet Creation: We create a subnet that will be part of the VPC created in the previous step. This defines a range of IP addresses in the VPC where resources such as EC2 instances can be placed.

    • EKS Cluster Creation: We create a new EKS cluster within the VPC. The eks.Cluster resource abstracts away many of the details involved in setting up an EKS cluster. When you instantiate this resource, by default Pulumi configures the EKS cluster with sensible defaults and best practices, like enabling control plane logging and setting up the necessary IAM roles and policies.

    • Kubernetes Provider: Once the EKS cluster is provisioned, we need a way to communicate with it. For this, we configure a Kubernetes provider instance using the kubeconfig that is generated upon cluster creation.

    • Helm Chart Deployment: We deploy the keptn-addons helm chart to the EKS cluster. We specify the chart name, the repository where the chart can be found, and optionally the version of the chart and the namespace where it should be deployed.

    • Export kubeconfig: Finally, we export the kubeconfig of the cluster which can be used to interact with Kubernetes cluster using kubectl command from your local machine.

    To deploy this program:

    1. Save the code to a file named index.ts.
    2. Run pulumi up to preview and deploy the changes.

    Ensure you have all the required permissions in AWS, the correct kubeconfig setup for Pulumi to access the EKS cluster, and Helm installed. If the Helm chart requires specific values or configurations, modify the keptnAddonsChart object accordingly.