1. Answers
  2. Deploy Loki Helm Chart on AWS EKS

How do I deploy the Loki Helm chart on AWS EKS?

In this guide, we will demonstrate how to deploy the Loki Helm chart on an AWS EKS cluster using Pulumi. Loki is a log aggregation system designed to store and query logs from various sources. By the end of this tutorial, you will have a running Loki instance on your EKS cluster.

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 new VPC for our EKS cluster
const vpc = new aws.ec2.Vpc("vpc", {
    cidrBlock: "10.0.0.0/16",
    enableDnsHostnames: true,
    enableDnsSupport: true,
});

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

// Create an EKS cluster
const cluster = new eks.Cluster("eksCluster", {
    vpcId: vpc.id,
    subnetIds: [subnet.id],
    instanceType: "t3.medium",
    desiredCapacity: 2,
    minSize: 1,
    maxSize: 3,
});

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

// Create a Kubernetes provider instance using the cluster's kubeconfig
const k8sProvider = new k8s.Provider("k8sProvider", {
    kubeconfig: cluster.kubeconfig,
});

// Deploy the Loki Helm chart
const loki = new k8s.helm.v3.Chart("loki", {
    chart: "loki",
    version: "2.4.1",
    fetchOpts: {
        repo: "https://grafana.github.io/helm-charts",
    },
    values: {
        persistence: {
            enabled: true,
            size: "10Gi",
        },
        resources: {
            limits: {
                cpu: "500m",
                memory: "256Mi",
            },
            requests: {
                cpu: "250m",
                memory: "128Mi",
            },
        },
    },
}, { provider: k8sProvider });

// Export the Loki service URL
export const lokiUrl = loki.getResource("v1/Service", "loki").status.loadBalancer.ingress[0].hostname;

Key Points

  1. VPC Creation: We start by creating a new VPC with DNS support enabled.
  2. Subnet Creation: A subnet is created within the VPC to host our EKS cluster.
  3. EKS Cluster: An EKS cluster is provisioned with the specified instance type and capacity.
  4. Kubernetes Provider: We create a Kubernetes provider instance using the EKS cluster’s kubeconfig.
  5. Loki Helm Chart: Finally, we deploy the Loki Helm chart on the EKS cluster with specified resource limits and persistence enabled.

Summary

We have successfully deployed the Loki Helm chart on an AWS EKS cluster using Pulumi. This setup includes creating a VPC, provisioning an EKS cluster, and deploying Loki using Helm. The Loki service URL is exported for easy access.

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