1. Deploy the Knative helm chart on AWS EKS

    TypeScript

    To deploy the Knative Helm chart on AWS EKS, you'll first need to create an EKS Cluster, and then use the Helm Chart resource from Pulumi's Kubernetes provider to deploy Knative into that cluster. Here's a step-by-step process:

    1. Set up an EKS Cluster: You’ll start by creating an instance of the EKS cluster using the eks.Cluster class from the Pulumi EKS package. This will set up all the necessary components for an EKS Cluster on AWS, including the required roles and security groups.

    2. Deploy Knative via Helm Chart: Once the EKS cluster is in place, you’ll deploy Knative to it using the kubernetes.helm.v3.Chart class from the Pulumi Kubernetes provider. You'll specify the Knative Helm chart and any necessary configuration values required for the deployment.

    Here's how you can accomplish this with Pulumi using TypeScript:

    import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as aws from "@pulumi/aws"; // Step 1: Create an EKS cluster const vpc = new aws.ec2.Vpc("my-vpc", { cidrBlock: "10.100.0.0/16", enableDnsHostnames: true, enableDnsSupport: true, }); const subnet = new aws.ec2.Subnet("my-subnet", { vpcId: vpc.id, cidrBlock: "10.100.1.0/24", mapPublicIpOnLaunch: true, availabilityZone: "us-west-2a", }); const cluster = new eks.Cluster("my-k8s-cluster", { // Define the VPC and subnets where the EKS cluster will run vpcId: vpc.id, publicSubnetIds: [subnet.id], // Optional: Define the desired version and node count of the cluster version: "1.21", // Specify the exact version you want desiredCapacity: 2, minSize: 1, maxSize: 3, // Optional: Define the instance type to use for the worker nodes instanceType: "t3.medium", }); // Step 2: Deploy Knative using the Helm chart const knativeChart = new k8s.helm.v3.Chart("knative", { chart: "knative", version: "0.20.0", // This should be the version of Knative Helm chart you wish to deploy fetchOpts:{ repo: "https://knative.dev/charts", }, namespace: "knative-serving", // The namespace where Knative will be installed }, { provider: cluster.provider }); // Export the cluster's kubeconfig and the Knative Service URL (once it's available) export const kubeconfig = cluster.kubeconfig; export const knativeServiceUrl = cluster.getKubeconfig().then(kc => { return new k8s.core.v1.Service("knative-service", { metadata: { namespace: "knative-serving", name: "<your-service-name>", // Replace this with your actual service name deployed by Knative }, }, { provider: new k8s.Provider("k8s-provider", { kubeconfig: kc })}).status.loadBalancer.ingress[0].hostname; });

    Let's break down the program:

    • We start by creating the necessary AWS resources, such as a VPC and subnets for our EKS cluster.
    • With the eks.Cluster class, we create a managed Kubernetes cluster on AWS EKS.
    • We set the desired number of nodes, node size, and the Kubernetes version.
    • Next, using the kubernetes.helm.v3.Chart class, we deploy Knative from its Helm chart to the EKS cluster we just created.
    • We specify the Helm chart version and repository from which to fetch it; be sure to check for the most recent or desired chart version and update the version field accordingly.
    • In the knativeServiceUrl, we are assuming you have a Knative service deployed that you would like to access externally. Replace <your-service-name> with the actual name of your Knative Service.

    Finally, the program exports the kubeconfig of the cluster, which you can use to interact with your cluster using kubectl, and the Knative Service URL if you have a specific service you wish to access.

    Notice that we've used placeholder values in some places, such as <your-service-name>. You should replace these with your actual values.

    To apply this Pulumi program:

    • Ensure that you have Pulumi CLI installed and configured for the AWS provider.
    • Ensure that you have Helm CLI and kubectl installed.
    • Save the program in a TypeScript file (e.g., index.ts).
    • Run pulumi up to create the cluster and deploy the Knative Helm chart.

    It's important to note that while Knative should work with default configurations, you may need to tweak the Helm chart values based on your specific needs or cluster configuration.