Deploy the krakend helm chart on AWS EKS
TypeScriptTo deploy the KrakenD Helm chart on an AWS Elastic Kubernetes Service (EKS) cluster using Pulumi, you will need to follow these steps:
- Set up an EKS cluster where KrakenD will reside.
- Configure your Kubernetes provider to connect to the EKS cluster.
- Deploy the KrakenD Helm chart using Pulumi's Kubernetes library.
Below is a Pulumi program written in TypeScript that demonstrates how to perform these steps. You should already have Pulumi and the necessary AWS and Kubernetes CLI tools configured on your machine. The program will:
- Create an EKS cluster using the
eks.Cluster
resource. - Set up an ECR (Elastic Container Registry) Repository, although it’s not part of deploying a Helm chart, I included it as it was mentioned in the registry results.
- Use the
kubernetes.helm.v3.Chart
resource to deploy the KrakenD Helm chart to the EKS cluster.
Make sure you have the necessary Helm chart repository added and updated in your local Helm configuration:
helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update
Now for the Pulumi program:
import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; // Create an EKS cluster. const cluster = new eks.Cluster("krakend-cluster", { desiredCapacity: 2, minSize: 1, maxSize: 3, instanceType: "t2.medium", providerCredentialOpts: { profileName: aws.config.profile, // Use AWS profile from configuration. }, }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Use the produced kubeconfig to connect to the EKS cluster. const provider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig, }); // Deploy the KrakenD Helm chart using the pulumi/kubernetes library. const krakendChart = new k8s.helm.v3.Chart("krakend-chart", { chart: "krakend", version: "1.2.3", // specify the version of the chart to deploy fetchOpts: { repo: "https://charts.bitnami.com/bitnami", // the repository where the chart is located }, }, { provider }); // Optionally, you might add an ECR repository if you'd like to store Docker images. const ecrRepo = new aws.ecr.Repository("krakend-ecr-repo"); // Export the ECR repository URL. export const repositoryUrl = ecrRepo.repositoryUrl;
In this program:
- We initiate the creation of an EKS cluster with
new eks.Cluster
. We specify the desired count and size of the nodes, as well as the instance type used for the worker nodes. You can adjust these values according to your needs. - We export the kubeconfig of the cluster, which is needed to interact with the cluster via
kubectl
. - We create a provider using
new k8s.Provider
and pass it the kubeconfig, which allows Pulumi to interact with our newly created cluster. - We deploy a Helm chart named
krakend
from the Bitnami Helm repository usingnew k8s.helm.v3.Chart
. You need to replace '1.2.3' with the actual version of the KrakenD Helm chart you wish to deploy. - Optionally we create an ECR repository with
new aws.ecr.Repository
. This step isn't strictly necessary for Helm deployment, but it's a common accompanying resource when working with EKS, as it allows us to store and manage Docker container images.
After this, you would execute the program using the usual Pulumi command sequence:
pulumi up
This will prompt you to confirm the deployment after showing you the proposed changes.
After a successful deployment, you can use the outputted kubeconfig to interact with your EKS cluster using
kubectl
or any Kubernetes compatible tools. You can also push images to the created ECR repository and use those images within your Kubernetes deployments.