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
- Ensure you have a Rancher-managed Kubernetes cluster.
- Install Pulumi CLI and configure it to use your preferred cloud provider (AWS in this case).
- Ensure you have Helm installed and configured.
Steps
- Create a new Pulumi project
pulumi new typescript
- Install the necessary Pulumi packages
npm install @pulumi/kubernetes @pulumi/aws
- Create a Pulumi stack
pulumi stack init dev
- Configure AWS credentials
pulumi config set aws:region us-west-2
- 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, });
- 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 });
- 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 upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.