简体   繁体   English

Kubernetes 集群上的 RabbitMQ 主机和端口

[英]RabbitMQ host and port on Kubernetes cluster

I've installed RabbitMQ on a Kubernetes Cluster using Helm as follows:我已经使用 Helm 在 Kubernetes 集群上安装了 RabbitMQ,如下所示:

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然后我设置了一个 Go 客户端像这样在同一个 Kubernetes 集群上作为服务运行

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?如何确定 Kubernetes 集群上的 RabbitMQ 的主机和端口应该设置为什么?

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.如果您的 Go 客户端在同一集群上作为微服务运行,则需要使用相应的 DNS 记录来访问它, localhost只是尝试访问 Go 客户端微服务本身。

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 .在安装了 RabbitMQ 的命名空间中,您可以运行kubectl get svc并且应该有一个使用端口 5672 运行的 ClusterIP 服务,可能称为my-release

You can then connect to it from any other service in the cluster with my-release.NAMESPACE.svc.DOMAIN .然后,您可以使用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 发行说明还显示了如何连接到服务,以及许多其他有用的说明,例如身份验证用户名和密码,以及外部访问可用性等。

helm get notes my-release

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM