Deploy the subscription helm chart on AWS EKS
TypeScriptDeploying a Helm chart to an Amazon Elastic Kubernetes Service (EKS) cluster involves several steps. First, you need to create an EKS cluster, and then, you deploy the Helm chart to that cluster. For this, you'll use various resources from the Pulumi
aws
,aws-eks
, andkubernetes
packages.Here is a breakdown of the steps you will take in the provided Pulumi program:
-
EKS Cluster Creation: Utilize the
eks.Cluster
from theaws-eks
package to create an EKS cluster. This is a high-level component that simplifies EKS cluster creation. -
Helm Chart Deployment: Once the cluster is ready, use the
kubernetes.helm.v3.Chart
from thekubernetes
package to deploy a Helm chart into the EKS cluster.
Note that in a real-world scenario, you'd need to configure your AWS credentials and the Kubernetes configuration so that Pulumi can interact with AWS and Kubernetes respectively. This generally includes setting up the AWS access keys in the environment variables and having
kubectl
configured to communicate with the cluster.Here is the detailed Pulumi TypeScript program that performs these actions:
import * as eks from "@pulumi/eks"; import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster with the default settings. // This will create all the necessary infrastructure for the cluster, // including the VPC, subnets, IAM roles, and security groups. const cluster = new eks.Cluster("my-cluster", {}); // Export the cluster's kubeconfig and its name so that we can easily access it. export const kubeconfig = cluster.kubeconfig; export const clusterName = cluster.eksCluster.name; // Once the cluster is created, we can deploy a Helm chart to it. // For this example, we will use a generic "nginx" Helm chart as a placeholder for your subscription chart. const nginxChart = new k8s.helm.v3.Chart("nginx", { chart: "nginx", version: "1.16.1", // replace with the exact version you need namespace: "default", // If you have specific configurations to pass to the chart, you can do so by adding a `values` parameter here. // values: { // <your-custom-configuration-keys>: <your-custom-configuration-values>, // }, fetchOpts: { // If your chart is hosted in a private or custom repository, // you can specify the `repo` property with the repository URL. // repo: "https://charts.helm.sh/subscription-chart-repo", }, }, { provider: new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeconfig }) }); // Expose any necessary service endpoints from the Helm chart deployment. // For example, if your Helm chart creates a LoadBalancer service, // you can export its endpoint like this: // export const serviceEndpoint = nginxChart.getResourceProperty("v1/Service", "my-nginx-service", "status").apply(status => status.loadBalancer.ingress[0].hostname); // Ensure that this pulumi program waits for the cluster to be available before trying to deploy Helm charts to it. // This is done by passing the `dependsOn` option in the second argument to the Helm chart resource.
In this program, you're creating an EKS cluster and deploying a sample "nginx" Helm chart. Replace "nginx" with the name of your subscription chart and specify any custom configuration values or a repository URL if needed.
This assumes that "nginx" is the placeholder name for your Helm chart. You would need to replace this with the actual name of the chart you're deploying, and possibly provide a custom repository URL and version number in the
fetchOpts
property.Remember that to apply this plan, you must have access to an AWS account and have your AWS credentials (such as
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
) configured, as well as Pulumi installed and set up on your machine. After runningpulumi up
with this program, Pulumi will provision the infrastructure and deploy your Helm chart to the EKS cluster.After the deployment, you can use the output
kubeconfig
to configurekubectl
and interact with your EKS cluster. If your chart exposed any services (e.g., via a LoadBalancer), you would export those details so you can access them outside of the Kubernetes cluster.-