Deploy the k8s-node-image-nginx-1-24 helm chart on AWS EKS
TypeScriptTo deploy a Helm chart on AWS EKS, you will need to follow these steps:
- Set up an EKS Cluster: You will need an EKS cluster where your Helm chart will be deployed. Using Pulumi's
eks
module is the easiest way to set up the cluster. - Install the Helm Chart: To install a Helm chart, you will use Pulumi's
kubernetes
provider. Before you can do this, you need to configure the Kubernetes provider to connect to the EKS cluster you created.
In this program, we will create an EKS cluster using the
eks.Cluster
resource. Then we will install the Nginx Helm chart using thekubernetes.helm.sh/v3.Chart
resource.Here's a complete program that accomplishes these tasks:
import * as eks from "@pulumi/eks"; import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster with the default configuration. 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. version: "1.24", // Specify the version of Kubernetes. }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses the EKS cluster's kubeconfig. const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy the 'k8s-node-image-nginx-1-24' Helm chart to the EKS cluster. const nginxChart = new k8s.helm.sh.v3.Chart("nginx", { chart: "nginx", version: "1.24", // You should replace this with the Helm chart version you want to deploy. namespace: "default", }, { provider: k8sProvider }); // Export the public endpoint of the Nginx service. export const nginxEndpoint = nginxChart.getResourceProperty("v1/Service", "nginx-nginx", "status") .apply(status => status.loadBalancer.ingress[0].hostname || status.loadBalancer.ingress[0].ip);
This program does the following:
- It creates an EKS cluster with the desired number of nodes and the specific version of Kubernetes.
- It exports the kubeconfig of the cluster, allowing you to interact with the cluster using tools like
kubectl
. - It creates a Kubernetes provider that's configured to communicate with the EKS cluster.
- It deploys the Nginx Helm chart on the EKS cluster within the
default
namespace using this Kubernetes provider. - It exports the public endpoint of the Nginx service, which can be used to access the Nginx server once it's deployed.
To run this program:
- Set up Pulumi and configure AWS access.
- Write this program in a file named
index.ts
. - Run
pulumi up
to create the resources.
Note: Helm chart versions change over time. Replace
1.24
with the exact chart version you want to deploy. Also, ensure that yourkubectl
is configured with the right context to deploy to the correct Kubernetes cluster if you're doing this manually.By the end of the
pulumi up
execution, you will have an EKS cluster running, and the Nginx server will be accessible at the output endpoint. Check the output of the pulumi command for the exact URL.Additional Resource Documentation:
- Set up an EKS Cluster: You will need an EKS cluster where your Helm chart will be deployed. Using Pulumi's