1. Deploy the OneUptime helm chart on AWS EKS

    TypeScript

    To deploy the OneUptime Helm chart on AWS EKS using Pulumi, you'll need to perform several steps:

    1. Create an EKS cluster: Define a Kubernetes cluster in AWS using Amazon EKS.
    2. Create an instance role for the EKS Nodes: Define an IAM role that will be used by the worker nodes in the EKS cluster.
    3. Deploy the OneUptime Helm chart: Use the Helm chart resource to deploy OneUptime onto the EKS cluster.

    Let's break down each step and provide corresponding Pulumi code in TypeScript to achieve this:

    Step 1: Create an EKS Cluster

    Here, we use the eks.Cluster resource to set up the EKS cluster:

    import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as eks from "@pulumi/eks"; // Create an EKS cluster. const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, // Specify the desired number of worker nodes minSize: 1, maxSize: 3, instanceType: "t2.medium", // Specify the instance type for the worker nodes providers: { kubernetes: k8sProvider }, // Pass the provider for Kubernetes resources }); // Export the kubeconfig for the cluster export const kubeconfig = cluster.kubeconfig;

    Step 2: Create an IAM Role for EKS Nodes

    This IAM role will give the EKS nodes the required permissions to operate within your AWS environment.

    // Create an IAM role for EKS node group. const nodeRole = new aws.iam.Role("nodeRole", { assumeRolePolicy: `{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" }] }`, }); new aws.iam.RolePolicyAttachment("nodeRolePolicyAttachment", { role: nodeRole, policyArn: "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", }); new aws.iam.RolePolicyAttachment("nodeRoleCniPolicyAttachment", { role: nodeRole, policyArn: "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", }); new aws.iam.RolePolicyAttachment("nodeRoleRegistryPolicyAttachment", { role: nodeRole, policyArn: "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly", });

    Step 3: Deploy the OneUptime Helm Chart

    We will deploy the OneUptime Helm chart to the EKS cluster using the helm.v3.Chart resource.

    import * as k8s from "@pulumi/kubernetes"; // Deploy the OneUptime Helm chart. const oneuptimeChart = new k8s.helm.v3.Chart("oneuptime", { chart: "oneuptime", version: "1.0.0", // Specify the chart version you want to deploy fetchOpts: { repo: "https://helm.oneuptime.com", // Replace with the correct OneUptime Helm repository }, values: { // Override default values here if needed }, }, { provider: cluster.provider }); // Export the URL for OneUptime export const oneuptimeUrl = oneuptimeChart.getResourceProperty("v1/Service", "my-cluster-oneuptime", "status").apply(status => `http://${status.loadBalancer.ingress[0].hostname}`);

    To compile and run this Pulumi program, you'll need Node.js and Pulumi installed on your machine. You also need to have the AWS CLI configured with the necessary credentials.

    1. Save the code in a file named index.ts.
    2. Run npm install to install the necessary Pulumi packages and their dependencies.
    3. Run pulumi up to create the resources on AWS and deploy the Helm chart.

    The resources will be created in the order they are defined because Pulumi understands the dependencies between them. The kubeconfig and oneuptimeUrl are exported so you can interact with your EKS cluster and the OneUptime application after deployment.