Deploy a scalable message queue A critical component of all the scalable architectures are message queues used to store and distribute messages to multiple parties and introduce buffering. Kafka is widely used in this space and there are multiple operators like Strimzi or to deploy it. For this project, use a sample app to demonstrate how your message queue works.
The app simply takes a POST to the producer url http://producer.denops.net which produces a message to a kafka topic to a specific group ID. The message is received by the receiver using a GET to the consumer url http://consumer.denops.net. The consumer appends the kafka message to a local file which is read after the request is completed. Both Kafka and the producer/consumer app are deployed to the
managed kubernetes cluster running in Digital Ocean. Included in the repo is the IaC to spin up the kubernetes cluster.
curl -X POST http://producer.denops.net
-H "Content-Type: application/json"
-d '{"message": "test"}'
http://consumer.denops.net/
Creating the infrastructure
Tools required:
Configure auth to Digital Ocean using doctl
- From the terraform directory
terraform apply - Type
yesand hitenterat the prompt
Creation of the kubernetes cluster will take some time. Approx 8 minutes.
- From the k8s directory
kubectl apply -f ./namespaces/ingress.yaml - Install the ingress via helm
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.publishService.enabled=true -n ingress
- Deploy the kafka namespace
kubectl apply -f ./k8s/namespaces/kafka.yaml
- Deploy the Strimzi CRD, roles, clusterroles, etc...
kubectl apply -f ./k8s/strimzi/strimzi-setup.yaml -n kafka
- Deploy the kafaka cluster
kubectl apply -f ./k8s/strimzi/strimzi-cluster.yaml
- Start a producer
kubectl -n kafka run kafka-producer -ti --image=quay.io/strimzi/kafka:0.26.0-kafka-3.0.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --broker-list cluster-kafka-bootstrap:9092 --topic my-topic
- From a new console start a consumer
kubectl -n kafka run kafka-consumer -ti --image=quay.io/strimzi/kafka:0.26.0-kafka-3.0.0 --rm=true --restart=Never -- bin/kafka-console-consumer.sh --bootstrap-server cluster-kafka-bootstrap:9092 --topic my-topic --from-beginning
- From the producer command line type a message and hit enter
> This is a test message
The consumer should receive and display the message
- Install tekton
kubectl apply -f ./k8s/tekton/tekton.yaml
- Install the tekton dashboard
kubectl apply -f ./k8s/tekton/tekton-dashboard-release.yaml
- Create the docker image and push to your repo of your choice.
kubectl apply -f ./apps/producer/producer.yaml
- Create the docker image and push to your repo of your choice.
kubectl apply -f ./apps/consumer/consumer.yaml
Distributed under the MIT License. See LICENSE.txt for more information.