Running Kafka on a Single Node in K8s Cluster
Buildbot Technologies Private Limited
We build your idea, We operate your product and We transfer the ownership
Introduction to Kafka:
Certainly! Apache Kafka is an open-source stream processing platform widely used for building real-time data pipelines and streaming applications. It was originally developed by LinkedIn and later open-sourced as an Apache project.
Here are some key points about Kafka that you might find useful for your blog:
1. Overview:
2. Architecture:
3. Topics and Partitions:
4. Producers and Consumers:
5. Durability and Replication:
6. Scalability:
Why Kafka Without ZooKeeper?
Kafka uses the Raft consensus algorithm for leader election in its Kafka Raft Metadata mode, which eliminates the dependency on ZooKeeper for managing cluster metadata. The Raft algorithm is a consensus protocol designed to ensure fault-tolerant replication of state machines in a distributed system.
Prerequisites:?
1. We need to pre-set up the Kubernetes cluster.
2. We need to install Helm.
3. We need to install Git.
Deployment Components:
1. Namespace:
?This is the namespace within which all components will be scoped.
2. Service Account:?
Service accounts control permissions and access to resources within the cluster.
3. Headless Service:?
It exposes ports 9092 (for Kafka clients) and 29093 (for Kafka Controller).
4.StatefulSet:?
It manages Kafka pods and ensures they have stable hostnames and storage.
Kafka cluster deployment without ZooKeeper
Step 1: After Helm & git installed, clone code from git-hub by the below command
?git clone https://github.com/siva-pra/kafka-single-pod.git
领英推荐
Step 2: Once the clone completed, Change the directory and untar the package.
cd kafka-single-pod && tar xvzf kafka-0.1.0.tgz
Step 3: Creating a namespace and deploying a kafka pod.
kubectl create namespace kafka
Step 4: Install Helm package and deploy Kafka controller pod
helm install kafka kafka -n kafka
Step 5: Now you can see that the Kafka pod is deployed successfully.
kubectl get all -n kafka
Step 6: Now login to kafka pod and perform the test
kubectl exec -it kafka-0 -n kafka -- /bin/bash
Note: While installing helm charts it creates a topic with the name “my-topic”
Step 7: Test Kafka Producer and Consumer
# Example producer command
kafka-console-producer.sh --bootstrap-server kafka-service:9092 --topic my-topic
Note: Take a new terminal and log into Kafka pod and type below command to check in the Consumer terminal
# Example consumer command
kafka-console-consumer.sh --bootstrap-server kafka-service:9092 --topic my-topic --from-beginning
Step 8: Cleanup
Provide instructions for uninstalling the Kafka Helm chart.
helm uninstall kafka -n kafka
This is how Running Kafka on a Single Node in K8s Cluster created.
I trust our DevOps team's article offered valuable insights. Whether you're a newcomer or an experienced professional, the journey of learning never ends. Buildbot serves as our collaborative platform, nurturing a culture of continuous learning within our community. Excited to hear your thoughts as we embark on this exploration and learning journey together! ??
#Buildbot #DevOps
Written By,
DevOps Team
Buildbot Technologies Private Limited