1. Answers
  2. Deploy The Loki-mixin Helm Chart On Rancher

Deploy the Loki-Mixin Helm Chart on Rancher

Deploying the Loki-Mixin Helm Chart on Rancher

Introduction

In this guide, we will deploy the Loki-Mixin Helm chart on a Rancher-managed Kubernetes cluster using Pulumi. Loki-Mixin is a set of Grafana dashboards and Prometheus rules for Loki, a log aggregation system. We will use Pulumi with TypeScript to manage the deployment.

Step-by-Step Explanation

Prerequisites

  1. Ensure you have a Rancher-managed Kubernetes cluster.
  2. Install Pulumi CLI and configure it to use your preferred cloud provider (AWS in this case).
  3. Ensure you have Helm installed and configured.

Steps

  1. Create a new Pulumi project
    pulumi new typescript
    
  2. Install the necessary Pulumi packages
    npm install @pulumi/kubernetes @pulumi/aws
    
  3. Create a Pulumi stack
    pulumi stack init dev
    
  4. Configure AWS credentials
    pulumi config set aws:region us-west-2
    
  5. Define the Kubernetes provider
    import * as k8s from "@pulumi/kubernetes";
    import * as aws from "@pulumi/aws";
    
    const cluster = new aws.eks.Cluster("my-cluster", {
        roleArn: "arn:aws:iam::123456789012:role/EKSClusterRole",
        vpcConfig: {
            subnetIds: ["subnet-12345678", "subnet-87654321"],
        },
    });
    
    const k8sProvider = new k8s.Provider("k8s-provider", {
        kubeconfig: cluster.kubeconfig,
    });
    
  6. Deploy the Loki-Mixin Helm chart
    const lokiMixin = new k8s.helm.v3.Chart("loki-mixin", {
        chart: "loki-mixin",
        version: "0.1.0",
        fetchOpts: {
            repo: "https://grafana.github.io/helm-charts",
        },
        values: {},
    }, { provider: k8sProvider });
    
  7. Run Pulumi up to deploy
    pulumi up
    

Summary

By following these steps, you will successfully deploy the Loki-Mixin Helm chart on your Rancher-managed Kubernetes cluster using Pulumi. This setup leverages AWS for the underlying infrastructure and uses Pulumi’s TypeScript SDK to manage the deployment process.

Full Code Example

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

// Create an EKS cluster
const cluster = new aws.eks.Cluster("my-cluster", {
    roleArn: "arn:aws:iam::123456789012:role/EKSClusterRole",
    vpcConfig: {
        subnetIds: ["subnet-12345678", "subnet-87654321"],
    },
});

// Export the cluster's kubeconfig
export const kubeconfig = pulumi.all([cluster.name, cluster.endpoint, cluster.certificateAuthority]).apply(([name, endpoint, certificateAuthority]) => {
    return \`apiVersion: v1
clusters:
- cluster:
    server: \${endpoint}
    certificate-authority-data: \${certificateAuthority.data}
  name: \${name}
contexts:
- context:
    cluster: \${name}
    user: aws
  name: \${name}
current-context: \${name}
kind: Config
preferences: {}
users:
- name: aws
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      command: aws-iam-authenticator
      args:
        - token
        - -i
        - \${name}
      # env:
        # - name: AWS_PROFILE
        #   value: "aws-profile"
\`;
});

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

// Deploy the Loki-Mixin Helm chart
const lokiMixin = new k8s.helm.v3.Chart("loki-mixin", {
    chart: "loki-mixin",
    version: "0.1.0",
    fetchOpts: {
        repo: "https://grafana.github.io/helm-charts",
    },
    values: {},
}, { provider: k8sProvider });

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