1. Deploy the loki-proxy helm chart on AWS EKS


    To deploy the loki-proxy Helm chart on AWS EKS, we'll complete the following steps:

    1. Set up an AWS EKS Cluster: We'll create an Elastic Kubernetes Service (EKS) cluster, which serves as the environment where our Kubernetes applications will run.
    2. Create an IAM Role for the EKS Cluster: This gives the necessary permissions to the EKS cluster to make AWS API calls on your behalf.
    3. Deploy the Helm Chart: We'll use Pulumi’s Kubernetes provider to deploy the loki-proxy Helm chart to our EKS cluster.

    Below is the TypeScript program that accomplishes this:

    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. const cluster = new eks.Cluster('loki-proxy-cluster', { // Specify additional settings per your requirements here. }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance configured to our EKS cluster. const provider = new k8s.Provider('k8s-provider', { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy the loki-proxy Helm chart using the Pulumi Kubernetes provider. const lokiProxyChart = new k8s.helm.v3.Chart('loki-proxy', { chart: 'loki-proxy', // You can specify further customization here, such as version or values. // version: "<CHART_VERSION>", // values: { // <CONFIG_VALUES>, // } }, { provider }); // Export the URL of the load balancer once it's deployed const lokiProxyService = lokiProxyChart.getResource('v1/Service', 'loki-proxy'); export const lokiProxyUrl = lokiProxyService.status.apply(status => status.loadBalancer.ingress[0].hostname);

    Let me break down what each section of the code is doing:

    • EKS Cluster Initialization: The eks.Cluster class from the @pulumi/eks package is used to provision the AWS EKS cluster. We export the kubeconfig which is used to communicate with the Kubernetes cluster and will be needed to set up the Kubernetes provider.

    • Kubernetes Provider Configuration: The @pulumi/kubernetes provider is being set up with the kubeconfig from the EKS cluster. This provider is then used for all Kubernetes resources, ensuring they are provisioned in our EKS cluster.

    • Helm Chart Deployment: We use the k8s.helm.v3.Chart class from the @pulumi/kubernetes package to deploy the loki-proxy Helm chart to our EKS Cluster. Customization of the chart deployment (like version and configuration values) can be specified in the Chart resource declaration.

    • Service URL Export: After the Helm chart has been deployed, we extract the hostname from the LoadBalancer, assuming loki-proxy exposes a LoadBalancer service. This URL will be the endpoint through which you can access the loki-proxy.

    For this example to work, you'll need to have Pulumi installed, along with the necessary AWS credentials configured to create resources within your AWS account. You'll also need to specify the correct chart name, version, and configuration values for your loki-proxy deployment.

    You can run this program using the Pulumi CLI. Save the code in a file named index.ts, and use the following commands:

    # Login to Pulumi pulumi login # Create a new Pulumi project pulumi new typescript -y # Install dependencies npm install @pulumi/pulumi @pulumi/aws @pulumi/awsx @pulumi/eks @pulumi/kubernetes # Deploy the stack pulumi up

    Ensure that you have kubectl installed and configured with the kubeconfig that Pulumi outputs upon successfully creating the EKS cluster. After deploying, you will see the lokiProxyUrl in the Pulumi stack outputs, which you can use to access your loki-proxy instance.