Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud Stackland
  • What's new
  • Installation
    • All tutorials
    • Installing Stackland on Yandex BareMetal
    • Installing Stackland on Yandex Cloud VMs
    • Setting up external access to a pod in a cluster
    • All guides
      • Creating a cluster
      • Creating a topic
      • Creating a user
      • Connecting to a cluster
      • Deleting a cluster
      • Deleting a topic
      • Deleting a user
    • Projects
    • Resource model
  • Access management
  • Pricing policy
  • Diagnostics and troubleshooting

In this article:

  • Getting started
  • How to connect to an Apache Kafka® cluster
  1. Step-by-step guides
  2. Message broker
  3. Connecting to a cluster

Connecting to an Apache Kafka® cluster

Written by
Yandex Cloud
Updated at June 24, 2026
View in Markdown
  • Getting started
  • How to connect to an Apache Kafka® cluster

In this tutorial, we will analyze the kcat commands for external and internal connections to an Apache Kafka® cluster and send a message from the producer to the consumer.

If you need a quick look at cluster connection settings, use the Connect button on the cluster page in the management console. Clicking the button brings up the complete connection data.

The instructions below describe the manual kubectl-based scenario, which you can use as a fallback in case you need to get the connection properties via the CLI.

Getting startedGetting started

  1. Install kcat.
  2. If the project does not exist yet, create it: kubectl create namespace <project name>.
  3. Create an Apache Kafka® cluster.
  4. Create a topic.
  5. Create a user with administrator privileges.

How to connect to an Apache Kafka® clusterHow to connect to an Apache Kafka® cluster

External connection
Internal connection

Note

To connect to Apache Kafka® from outside the cluster, you must enable the public access option (listenerType: LoadBalancer) in the Apache Kafka® cluster settings.

  1. Get an external link to the Apache Kafka® cluster: kubectl get kafkaclusters <cluster name> -o jsonpath='{.status.listenersStatus.external.fqdn}' -n <project_name>.

  2. Get the port to connect to: kubectl get kafkaclusters <cluster name> -o jsonpath='{.status.listenersStatus.external.port}' -n <project name>.

  3. Copy the connection certificate from the Apache Kafka® cluster resource field named status.listenersStatus.external.certificate: kubectl describe kafkaclusters <cluster name> -n <project name>.

  4. Save the certificate to a file named <path to certificate>/ca.crt.

  5. Run the following command to receive messages from the topic:

    kcat -C \
    -b <link to cluster>:<port> \
    -t <topic name> \
    -X security.protocol=SASL_SSL \
    -X sasl.mechanism=SCRAM-SHA-512 \
    -X sasl.username="<username>" \
    -X sasl.password="<user password>" \
    -X ssl.endpoint.identification.algorithm=none \
    -X ssl.ca.location=/<path to certificate>/ca.crt -Z -K:
    
  6. Open a new terminal and send the following message to the topic:

    echo "test message" | kcat -P \
    -b <link to cluster>:<port> \
    -t <topic name> \
    -k key \
    -X security.protocol=SASL_SSL \
    -X sasl.mechanism=SCRAM-SHA-512 \
    -X sasl.username="<username>" \
    -X sasl.password="<user password>" \
    -X ssl.endpoint.identification.algorithm=none \
    -X ssl.ca.location=/<path to certificate>/ca.crt -Z
    

The consumer will receive a message: "test message".

  1. Get an internal link to the Apache Kafka® cluster: kubectl get kafkaclusters <cluster name> -o jsonpath='{.status.listenersStatus.internal.fqdn}' -n <project_name>.

  2. Get the port to connect to: kubectl get kafkaclusters <cluster name> -o jsonpath='{.status.listenersStatus.internal.port}' -n <project name>.

  3. Run the following command to receive messages from the topic:

    kcat -C \
    -b <link to cluster>:<port> \
    -t <topic name> \
    -X security.protocol=SASL_PLAINTEXT \
    -X sasl.mechanism=SCRAM-SHA-512 \
    -X sasl.username="<username>" \
    -X sasl.password="<user password>" -Z -K:
    
  4. Open a new terminal and send the following message to the topic:

    echo "test message" | kcat -P \
    -b <link to cluster>:<port> \
    -t <topic name> \
    -k key \
    -X security.protocol=SASL_PLAINTEXT \
    -X sasl.mechanism=SCRAM-SHA-512 \
    -X sasl.username="<username>" \
    -X sasl.password="<user password>" -Z
    

The consumer will receive a message: "test message".

Was the article helpful?

Previous
Creating a user
Next
Deleting a cluster
© 2026 Direct Cursus Technology L.L.C.