Deploy the fn helm chart on AWS EKS
TypeScriptTo deploy the
fn
Helm chart on AWS EKS using Pulumi, you'll need to complete a few tasks:- Create an EKS cluster where your Helm chart will be deployed.
- Configure the Kubernetes provider to deploy resources onto the EKS cluster.
- Deploy the
fn
Helm chart using the Kubernetes provider.
Below is a detailed TypeScript program that does just that.
Firstly, you need to create an EKS cluster. The
eks.Cluster
from the Pulumi EKS package is a high-level component that abstracts away the details of creating an EKS cluster. It will automatically create the VPC, subnets, and node group required for the cluster.With the cluster created, you'll set up the Kubernetes provider. This provider interacts with the EKS cluster and arranges for Kubernetes resources, such as the
fn
Helm chart, to be deployed.Finally, you'll deploy the
fn
Helm chart. Thekubernetes.helm.v3.Chart
resource from the Pulumi Kubernetes provider represents a Helm chart. You will pass in required values such as the Helm chart name and version, and Pulumi will ensure the chart gets deployed onto the EKS cluster.Here's a TypeScript program for deploying the
fn
Helm chart on AWS EKS:import * as eks from "@pulumi/eks"; import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster. const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, // Specify the desired number of cluster nodes. minSize: 1, // Specify the minimum number of cluster nodes. maxSize: 3, // Specify the maximum number of cluster nodes. storageClasses: "gp2", // Specify the default storage class. deployDashboard: false, // Indicate if the Kubernetes dashboard is deployed or not. }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses the EKS cluster's kubeconfig. const provider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig, }); // Deploy the `fn` Helm chart on the EKS cluster using the Kubernetes provider. const fnChart = new k8s.helm.v3.Chart("fn-chart", { chart: "fn", version: "0.5.0", // Specify the chart version you want to deploy. fetchOpts: { repo: "https://fnproject.github.io/charts", // URL to the Helm repository. }, }, { provider: provider }); // Export the public endpoint of the `fn` service, if available. const fnService = fnChart.getResource("v1/Service", "default", "fn"); export const fnEndpoint = fnService.status.loadBalancer.ingress[0].hostname;
In the code above:
- An EKS cluster named
my-cluster
with a default node count between 1 and 3 is created. - A new Kubernetes provider is instantiated, which uses the EKS cluster's kubeconfig for authentication.
- The
fn
Helm chart is deployed on the EKS cluster. Replace0.5.0
with the actual version of thefn
chart you wish to use. - The endpoint to access the
fn
service is exported, assuming the service type is LoadBalancer and is provisioned with a public endpoint (adjust as needed based on your actual service setup).
The code ends by exporting
kubeconfig
andfnEndpoint
, allowing you to interact with the EKS cluster and access your deployedfn
service.To apply this Pulumi program, you'd save it to a file named
index.ts
and runpulumi up
within the same directory. Make sure you have AWS access configured, and have installed the necessary Pulumi CLI and npm packages.