Deploy the aws-spot-termination-handler helm chart on Kubernetes
TypeScriptTo deploy the
aws-spot-termination-handler
Helm chart on Kubernetes using Pulumi, you will first need to ensure you have a Kubernetes cluster available, and you are authenticated to it. We will leverage the@pulumi/kubernetes
package to work with Kubernetes resources, which allows us to define and deploy Helm charts as if they were native Pulumi resources.Below is a Pulumi TypeScript program that accomplishes the deployment of the
aws-spot-termination-handler
Helm chart. This program creates a Helm chart resource referring to the Helm chart we want to deploy.To explain the main components of this Pulumi program:
- We import the necessary Pulumi Kubernetes library.
- We then create an instance of the
Chart
resource. In this case, theChart
resource points to theaws-spot-termination-handler
chart from its repository. - We pass the required
values
to configure the Helm chart, if needed. For this example, we'll assume the default values are acceptable. - We specify the namespace where this chart will be deployed in.
Before running the program, ensure you have Pulumi installed, and you are authenticated with your Kubernetes cluster. You should also have set up your Pulumi stack using
pulumi stack init
.Here is the program:
import * as k8s from "@pulumi/kubernetes"; // Create a new Helm Chart for the aws-spot-termination-handler. // Replace `CHART_VERSION` with the desired chart version. const awsSpotTerminationHandlerChart = new k8s.helm.v3.Chart("aws-spot-termination-handler", { chart: "aws-spot-termination-handler", version: "CHART_VERSION", fetchOpts: { repo: "https://aws.github.io/eks-charts", // Helm chart repository containing the chart }, namespace: "kube-system", // Namespace where to deploy the chart // If you have custom values, you can include them here, for example: // values: { // replicaCount: 2, // }, }); // Export the resources' name of the Chart. export const chartName = awsSpotTerminationHandlerChart.metadata.apply(metadata => metadata.name);
Upon running this Pulumi program, it will contact the Helm chart repository specified (
https://aws.github.io/eks-charts
), download theaws-spot-termination-handler
Helm chart, and deploy it to the Kubernetes cluster in thekube-system
namespace. You can configure thevalues
property with any custom values that you would like to apply to the chart upon installation.Please replace
CHART_VERSION
with the actual chart version you intend to deploy. If you're unsure of the available chart versions, you can look them up using thehelm search repo
command or by visiting the chart's repository.You can run the Pulumi program by issuing the
pulumi up
command in the same directory as the file. This will initiate the Pulumi deployment process, during which it will show you a preview of the resources to be created, and ask for a confirmation before proceeding with the actual deployment.Make sure to review the Helm chart documentation to understand the default values and any optional values you might want to override to customize your deployment.