Deploy the generic-secrets helm chart on AWS EKS
TypeScriptDeploying a Helm chart on an AWS Elastic Kubernetes Service (EKS) cluster involves several steps. You will first need an EKS cluster up and running. This program will demonstrate how to create an EKS cluster and deploy a Helm chart for
generic-secrets
using Pulumi with TypeScript.Before starting with the Pulumi program, ensure you have the following prerequisites:
- Pulumi CLI installed and configured with your AWS account.
- AWS CLI installed and configured with your AWS account.
- Kubernetes CLI (
kubectl
) installed to interact with the EKS cluster. - Helm CLI (
helm
) installed to manage Helm charts.
The following Pulumi program performs two key actions:
- Sets up an EKS cluster by using the
@pulumi/eks
package, which simplifies the creation of EKS clusters. - Deploys a Helm chart to the EKS cluster using the
@pulumi/kubernetes
package. In this case, we will simulate the deployment of ageneric-secrets
chart by deploying an example chart namednginx
.
Let's start by creating the EKS cluster and then deploying the Helm chart to it.
import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster const cluster = new eks.Cluster("my-cluster", { desiredCapacity: 2, minSize: 1, maxSize: 3, storageClasses: "gp2", deployDashboard: false, }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses our EKS cluster. const provider = new k8s.Provider("provider", { kubeconfig: cluster.kubeconfig, }); // Deploy the `generic-secrets` helm chart. const genericSecretsChart = new k8s.helm.v3.Chart("generic-secrets", { chart: "nginx", // This is an example. You should use the actual chart for `generic-secrets`. version: "1.17.10", // Specify the chart version you want to deploy. fetchOpts: { repo: "https://charts.helm.sh/stable", // Replace with the actual Helm repo URL for `generic-secrets`. }, }, { provider }); // Ensure that the Helm chart is deployed using the EKS cluster's kubeconfig. // Export the deployment name of the Helm chart. export const helmDeploymentName = genericSecretsChart.getResourceName("v1/Service", "generic-secrets");
Here is what each part of this program does:
-
The
eks.Cluster
resource represents an EKS cluster. ThedesiredCapacity
,minSize
, andmaxSize
are configurations for the cluster's node group that dictate the scaling properties. You can adjust these properties based on your requirements. -
The
kubeconfig
export allows you to use your EKS cluster outside of Pulumi, with tools such askubectl
. -
A
k8s.Provider
is created, representing the ability to deploy resources into the Kubernetes cluster we have created. It uses thekubeconfig
from the EKS cluster so that it can communicate with it. -
The
k8s.helm.v3.Chart
resource is used to deploy Helm charts. Here, for demonstration purposes, the program uses thenginx
chart as an example since the actual chart forgeneric-secrets
is not specified. Replace"nginx"
with the name of the chart you want to deploy and therepo
field with the repository that houses thegeneric-secrets
chart.
To execute this Pulumi program, save it to a
index.ts
file, and then run the following commands in your terminal:pulumi up
This will prompt Pulumi to provision the AWS EKS cluster and deploy the Helm chart as defined. Once deployed,
kubeconfig
andhelmDeploymentName
will be outputted, which you can use to interact with your EKS cluster and deployed Helm chart.Please replace "nginx" and the respective version number and repository with the actual chart details of
generic-secrets
that you wish to install on your cluster.