This guide explains how to set up Apache Kafka and Kafdrop using Kubernetes or Docker Compose, and how to run your application.
Before you begin, ensure you have the following installed:
- Docker
- Docker Compose
- kubectl
- Node.js (for running your application)
- npm (for installing dependencies)
Install the required dependencies for your application:
npm installYou can use either Kubernetes or Docker Compose to run Kafka and Kafdrop.
Apply the Kubernetes manifests:
kubectl apply -f k8s/Verify that the pods are running:
kubectl get podsForward the ports to access Kafka and Kafdrop locally:
kubectl port-forward svc/kafka-broker 9092:9092
kubectl port-forward svc/kafdrop 9000:9000Start the services using Docker Compose:
docker-compose up -dVerify that the containers are running:
docker-compose ps- Kafka will be available at
localhost:9092. - Kafdrop (Kafka UI) will be available at http://localhost:9000.
Once Kafka and Kafdrop are running, start your application:
npm run startEnsure Kafka is running and the ports are forwarded correctly.
Check the logs for errors:
Using Kubernetes:
kubectl logs <kafka-pod-name>or
Using Docker Compose:
docker-compose logs kafka-brokerEnsure Kafdrop is running and port 9000 is forwarded.
Check the logs for errors:
Using Kubernetes:
kubectl logs <kafdrop-pod-name>or
Using Docker Compose:
docker-compose logs kafdropTo delete Kubernetes resources:
kubectl delete -f k8s/To stop and remove Docker containers:
docker-compose downThis project is licensed under the MIT License. See the LICENSE file for details.