Deploy the simple-redis helm chart on AWS EKS
TypeScriptTo deploy the
simple-redis
Helm chart on an Amazon EKS cluster using Pulumi, first, an EKS cluster is required. This can be setup using Pulumi’seks.Cluster
resource. After the cluster has been created, thekubernetes.helm.v3.Chart
resource can then be used to deploy thesimple-redis
chart to the new EKS cluster.Here are the steps and code written in TypeScript to achieve this:
-
Set up an EKS Cluster: Create an EKS Cluster with the
eks.Cluster
resource which simplifies managing the EKS cluster instances and related resources in AWS. EKS integrates Kubernetes with AWS services and requires a defined IAM role for the cluster and node groups. -
Deploy the Helm Chart: Use the
kubernetes.helm.v3.Chart
resource to deploy thesimple-redis
Helm chart into the EKS cluster. The Helm chart abstraction in Pulumi allows you to deploy existing Helm charts into your Kubernetes clusters.
Below is a Pulumi program in TypeScript that accomplishes this:
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", { // Define desired settings for the cluster. desiredCapacity: 2, minSize: 1, maxSize: 2, // Pick the right version for the Helm chart or your requirements. version: "1.21", }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Deploy the simple-redis Helm chart into the cluster. const redisChart = new k8s.helm.v3.Chart("simple-redis", { chart: "redis", version: "10.5.7", // Specify the version that corresponds to 'simple-redis'. fetchOpts: { repo: "https://charts.bitnami.com/bitnami", }, }, { provider: cluster.provider }); // Export the Redis host export const redisHost = redisChart.getResourceProperty("v1/Service", "simple-redis-master", "status").apply(status => status.loadBalancer.ingress[0].hostname);
Explanation:
- An EKS cluster named
my-cluster
is defined with the necessary configuration such as desired node count and Kubernetes version. - The Kubernetes configuration is exported through
kubeconfig
, which allows you to interact with your cluster usingkubectl
or any other Kubernetes management tool. - The
simple-redis
Helm chart is then deployed to the EKS cluster. We usechart: "redis"
assumingsimple-redis
is a redis chart, and we specify the version to use. - It's assumed that
simple-redis
corresponds to a version of the Redis chart from Bitnami's Helm repository. The repo URL is passed to thefetchOpts
to locate the chart. - The provider associated with the EKS cluster is passed to ensure the Helm chart is deployed using the EKS cluster's context.
- Finally, the hostname for the Redis service, which can be used to interact with Redis, is exported.
When you run this Pulumi program with
pulumi up
command, it will create an EKS cluster and deploy thesimple-redis
Helm chart in the cluster.Make sure you have Pulumi installed and AWS credentials configured. Since the example above assumes that
simple-redis
is a redis chart from Bitnami, you may need to substitute the correct chart name and version based on the actual chart you wish to deploy.-