This setup creates several pods that host a RabbitMQ conversation between two Kubernetes pods: a producer and a consumer. The producer sends messages to a RabbitMQ service, and the consumer reads and displays them.
- Kubernetes cluster
kubectlcommand-line tool- Docker
- Access to a container registry
- Lumigo
Do a global search/replace <your-registry-path> with your target registry name. Should be 9 results in the following files for this project: k8/rabbitmq-producer.yaml k8/rabbitmq-consumer.yaml README.md
Search/Replace <your-lumigo-token> in this README.md with your Lumigo token found from the Lumigo UI under Settings->Tracing in the Lumigo UI
helm repo add lumigo https://lumigo-io.github.io/lumigo-kubernetes-operator
helm install lumigo lumigo/lumigo-operator --namespace lumigo-system --create-namespaceSee https://docs.lumigo.io/docs/lumigo-kubernetes-operator for more information
Create a namespace called rabbitmq:
kubectl create namespace rabbitmqkubectl create secret generic --namespace rabbitmq lumigo-credentials --from-literal token=<your-lumigo-token>You can view the token to validate by running the following:
kubectl get secret lumigo-credentials -n rabbitmq -o json | jq -r '.data.token' | base64 -decho '{
"apiVersion": "operator.lumigo.io/v1alpha1",
"kind": "Lumigo",
"metadata": {
"name": "lumigo"
},
"spec": {
"lumigoToken": {
"secretRef": {
"name": "lumigo-credentials",
"key": "token"
}
}
}
}' | kubectl apply -f - --namespace rabbitmqFor the Microsoft Windows command line you should to run the folllowing command
kubectl apply -f k8/lumigo.yaml -n rabbitmqTo deploy RabbitMQ as a service within the rabbitmq namespace:
kubectl apply -f k8/rabbitmq-setup.yaml -n rabbitmqpushd src/producer
docker build -t <your-registry-path>/rabbitmq-producer:latest .
docker push <your-registry-path>/rabbitmq-producer:latest
popdpushd src/consumer
docker build -t <your-registry-path>/rabbitmq-consumer:latest .
docker push <your-registry-path>/rabbitmq-consumer:latest
popdkubectl apply -f k8/rabbitmq-producer.yaml -n rabbitmqkubectl apply -f k8/rabbitmq-consumer.yaml -n rabbitmqkubectl create secret generic --namespace rabbitmq lumigo-credentials --from-literal token=<your-lumigo-token>You can view the token to validate by running the following:
kubectl get secret lumigo-credentials -n rabbitmq -o json | jq -r ".data.token" | base64 -dThe producer sends messages every 5 seconds to the RabbitMQ service. The consumer consumes and displays them.
To view logs from the producer:
kubectl logs -l app=rabbitmq-producer -n rabbitmqTo view logs from the consumer:
kubectl logs -l app=rabbitmq-consumer -n rabbitmqTo remove all the deployed resources:
kubectl delete -f k8/rabbitmq-setup.yaml -n rabbitmq
kubectl delete -f k8/rabbitmq-producer.yaml -n rabbitmq
kubectl delete -f k8/rabbitmq-consumer.yaml -n rabbitmq
kubectl delete namespace rabbitmqkubectl get pods -n rabbitmq
kubectl describe pod -l app=rabbitmq-producer -n rabbitmq
kubectl describe pod -l app=rabbitmq-consumer -n rabbitmq
kubectl logs -l app=rabbitmq-producer -n rabbitmq
kubectl logs -l app=rabbitmq-consumer -n rabbitmq