Deploy the kafka-topic-exporter helm chart on Kubernetes
TypeScriptTo deploy the
kafka-topic-exporter
Helm chart on Kubernetes using Pulumi, we will primarily use theChart
resource from Pulumi's Kubernetes provider. This resource allows us to deploy Helm charts to a Kubernetes cluster in a declarative manner.Before you begin, you should have the following prerequisites in place:
- Pulumi CLI installed on your local machine.
- Kubernetes cluster up and running.
- Kubeconfig file configured to point to your Kubernetes cluster.
- Helm chart repository that contains the
kafka-topic-exporter
chart.
The Pulumi program outlined below will:
- Set up a new Kubernetes provider instance using the current context from your kubeconfig.
- Define a
Chart
resource for thekafka-topic-exporter
Helm chart, with configuration to set values or overrides as needed.
Here's a step-by-step TypeScript program to accomplish the deployment:
import * as k8s from '@pulumi/kubernetes'; // This is where we create a new Helm chart instance. // The Chart resource will install the kafka-topic-exporter Helm chart from the specified repository. const kafkaTopicExporterChart = new k8s.helm.v3.Chart('kafka-topic-exporter', { chart: 'kafka-topic-exporter', version: 'chart-version', // Specify the chart version you want to deploy fetchOpts: { repo: 'https://your-helm-chart-repo', // Replace with the actual chart repository URL }, // Values in the `values` object override the default chart values. // For example, if you need to specify the Kafka broker service details, // you can set them inside the values block like below. values: { kafka: { service: { // Service details for the Kafka broker, adjust as required. brokers: 'kafka:9092', }, }, // Other required chart values can go here }, }); // When the program runs, it will apply the `kafka-topic-exporter` Helm chart into the Kubernetes cluster. // You can access any exported properties through the `kafkaTopicExporterChart` variable.
Please replace
chart-version
, andhttps://your-helm-chart-repo
with the respective chart version and Helm chart repository URL that hosts thekafka-topic-exporter
chart.As you can see, we don't need to manually handle Helm CLI commands — Pulumi takes care of interpreting and applying the Helm chart for us directly from our code.
Keep in mind this is a basic example. The configuration may vary depending on the specifics of the
kafka-topic-exporter
chart and your service requirements, such as custom configurations, namespaces, and so on. You should review thevalues.yaml
file of thekafka-topic-exporter
Helm chart and adjust thevalues
object in the code accordingly to fit your needs.After writing this Pulumi program, you would run it using the Pulumi CLI:
- Navigate to the directory where this file is saved.
- Run
pulumi up
to preview and deploy the changes to your cluster.
The Pulumi CLI outputs the progress and results of the deployment, and if everything is configured correctly, it will successfully deploy the
kafka-topic-exporter
Helm chart to your cluster.