Adrian
Adrian

Reputation: 104

RabbitMQ host and port on Kubernetes cluster

I've installed RabbitMQ on a Kubernetes Cluster using Helm as follows:

helm repo add bitnami https://charts.bitnami.com/bitnami

helm install my-release bitnami/rabbitmq-cluster-operator

Then I setup a Go Client something like this running as a service on the same Kubernetes Cluster

import amqp "github.com/rabbitmq/amqp091-go"

conn, err = amqp.Dial("amqp://guest:guest@localhost:5672/")

But the client fails to connect. How do I figure out what the host and port should be set to for RabbitMQ on a Kubernetes Cluster?

Upvotes: 0

Views: 1713

Answers (1)

clarj
clarj

Reputation: 1044

If your Go client is running as a microservice on the same cluster, you need to use the appropriate DNS record to access it, localhost just attempts to access the Go client microservice itself.

In the namespace where RabbitMQ is installed, you can run kubectl get svc and there should be a ClusterIP service running with port 5672, likely called my-release.

You can then connect to it from any other service in the cluster with my-release.NAMESPACE.svc.DOMAIN.

The Helm release notes also show how to connect to the service, as well as many other helpful notes like authentication username and password, as well as external access availability etc.

helm get notes my-release

Upvotes: 1

Related Questions