1. Answers
  2. Deploy The Kubecost Helm Chart On AWS EKS

Deploy the Kubecost Helm Chart on AWS EKS

Introduction

In this guide, we will deploy the Kubecost Helm chart on an AWS EKS cluster using Pulumi. Kubecost is a cost monitoring and management tool for Kubernetes clusters. We will use TypeScript as our programming language, in accordance with the organization’s preferences.

Step-by-Step Explanation

Step 1: Set Up Pulumi Project

  1. Initialize a new Pulumi project using TypeScript.
  2. Install the necessary Pulumi packages for AWS and Kubernetes.

Step 2: Create an EKS Cluster

  1. Define the VPC and subnets for the EKS cluster.
  2. Create the EKS cluster with the necessary configurations.

Step 3: Deploy the Kubecost Helm Chart

  1. Add the Kubecost Helm repository.
  2. Deploy the Kubecost Helm chart to the EKS cluster.

Step 4: Export the EKS Cluster Configuration

  1. Export the kubeconfig to interact with the EKS cluster.

Conclusion

By following these steps, you will have successfully deployed the Kubecost Helm chart on an AWS EKS cluster using Pulumi. This setup will allow you to monitor and manage the costs associated with your Kubernetes workloads effectively.

Full Code Example

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as eks from "@pulumi/eks";
import * as k8s from "@pulumi/kubernetes";

// Create a VPC for our cluster
const vpc = new aws.ec2.Vpc("vpc", {
    cidrBlock: "10.0.0.0/16",
    enableDnsHostnames: true,
    enableDnsSupport: true,
    tags: {
        Name: "pulumi-vpc",
    },
});

// Create subnets for the VPC
const subnet1 = new aws.ec2.Subnet("subnet1", {
    vpcId: vpc.id,
    cidrBlock: "10.0.1.0/24",
    availabilityZone: "us-west-2a",
    tags: { Name: "pulumi-subnet1" },
});

const subnet2 = new aws.ec2.Subnet("subnet2", {
    vpcId: vpc.id,
    cidrBlock: "10.0.2.0/24",
    availabilityZone: "us-west-2b",
    tags: { Name: "pulumi-subnet2" },
});

// Create an EKS cluster
const cluster = new eks.Cluster("eks-cluster", {
    vpcId: vpc.id,
    subnetIds: [subnet1.id, subnet2.id],
    instanceType: "t3.medium",
    desiredCapacity: 2,
    minSize: 1,
    maxSize: 3,
    enabledClusterLogTypes: ["api", "audit", "authenticator"],
    tags: { Name: "pulumi-eks-cluster" },
});

// Export the kubeconfig
export const kubeconfig = cluster.kubeconfig;

// Deploy the Kubecost Helm chart
const kubecost = new k8s.helm.v3.Chart("kubecost", {
    chart: "cost-analyzer",
    version: "1.87.0",
    fetchOpts: {
        repo: "https://kubecost.github.io/cost-analyzer/",
    },
    values: {
        kubecostToken: "<YOUR_KUBECOST_TOKEN>", // Replace with your Kubecost token
    },
}, { provider: cluster.provider });

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up