Deploy the business-service helm chart on AWS EKS
TypeScriptIn order to deploy a Helm chart on AWS Elastic Kubernetes Service (EKS), we need to perform several steps using Pulumi:
- Create an Amazon EKS cluster
- Deploy the Helm chart to the EKS cluster
We’ll use Pulumi's AWS, AWSX, and Kubernetes packages, as they provide high-level components that simplify the creation and management of EKS clusters and Helm charts on AWS.
Pulumi Program to Deploy a Helm Chart on AWS EKS
The following program will:
- Create an EKS cluster.
- Define the necessary role for the EKS cluster to operate.
- Deploy a Helm chart to the created EKS cluster.
Firstly, we'll create the EKS cluster:
import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; // Create an EKS cluster with the default settings. // This creates the cluster and the workers, all the necessary security groups, IAM roles, and so on. const cluster = new eks.Cluster("eks-cluster", {}); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig;
Next, we need to install and configure the Helm chart. Ensure you have the Helm chart's repository URL and the chart name (
business-service
) before you proceed. If your helm chart requires specific values, configure thevalues
object as needed.// Deploy a Helm chart to the EKS cluster // The Helm chart is hosted in some repository, and we should add this information // along with version and any custom values your chart requires. const chart = new k8s.helm.v3.Chart("business-service", { chart: "business-service", version: "1.0.0", // specify the exact version you want to deploy fetchOpts: { repo: "http://example.com/helm-charts", // replace with the actual Helm chart repository }, // Add any required custom values file or configuration values: { // serviceType should be configured according to the AWS EKS setup. // For example, if you want your service to be publicly available, you can use LoadBalancer serviceType: "LoadBalancer", }, }, { provider: cluster.provider });
Remember to replace
"http://example.com/helm-charts"
with the actual repository URL for your Helm chart, and fill out thevalues
object with the necessary values for your deployment.Now, after the deployment, if you want to access the deployed services, you would typically use the
kubectl
command-line tool with the exportedkubeconfig
.This is a basic example that assumes you are deploying a Helm chart using default values, which is often not the case in real-world scenarios. You might need to provide custom configurations based on the Helm chart's requirements.
Summary
The program above:
- Sets up the AWS EKS cluster using the Pulumi EKS package.
- Deploys a Helm chart to that cluster using the Pulumi Kubernetes package.
By running this Pulumi program, you will create an EKS cluster and then deploy your
business-service
Helm chart into it. Ensure you have the Pulumi CLI installed and configured to communicate with your AWS account. To apply this stack, you'll runpulumi up
, which will execute the deployment as per the defined script.