Question

How to setup kafka through pulumi on kubernetes cluster

Posted June 30, 2021 134 views
KubernetesDigitalOcean API and CLI (doctl)

Hi,
I’ve followed simple tutorial for creating K8S cluster on DO with Pulumi, but now I like to configure kafka provider from Pulumi on to the same cluster previously created.

I’m not sure how to achieve and if is possible to do it in simple manner, without extra scripts or manual editing of different kafka files.

So far, I have this code:


const kafkaProvider = new kafka.Provider(kafkaProviderName, {
  bootstrapServers: ["x.x.x.x:9092"],
}, { provider: kubernetesProvider });

export const topic = new kafka.Topic('demo-topic', {
  replicationFactor: 1,
  partitions: 1,
}, { provider: kafkaProvider });

export { kafkaProvider };

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

The Kafka provider creates resources within an existing Kafka cluster. Your example would create a new Topic by connecting to a Kafka cluster on that given IP and port.

If I understand correctly, you have a clean K8s cluster without Kafka installed on it yet. If so, you need to define another set of resources to provision a Kafka cluster on your K8s cluster.

Unfortunately, I don’t have an ready-to-use example of a Kafka installation. I suspect you may want to use a Helm chart for that. If so, this example shows how to provision a Helm chart with Pulumi: https://github.com/pulumi/examples/tree/master/kubernetes-ts-helm-wordpress

  • Hi,

    Yes. I need to go with helm or custom kafka kubernetes yaml files.
    I was thinking that the provider, provisioning kafka and installing on top of DO kubernetes cluster.
    But at the end, I’ve found out that this is just wrapper on top of terraform, which actually doing the same.

    BR,