.Net 应用程序无法连接到 minikube 上的 RabbitMQ

.Net application cant connect to RabbitMQ on minikube

我正在尝试将我的 .Net 应用程序 pod 连接到我在 minikube 中 运行 的 RabbitMQ pod。我尝试了所有类型的服务,因为它不起作用我尝试直接将 pods 与其在 pod 中的 IP 地址连接起来。即使这样,应用程序 pod 也无法连接到 RabbitMQ pod。

这是我遇到的错误

[05:40:31 INF] RabbitMQ Client is trying to connect
[05:40:39 WRN] RabbitMQ Client could not connect after 2.0s (None of the specified endpoints were reachable)
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
 ---> System.AggregateException: One or more errors occurred. (Connection failed)
 ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed
 ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable
   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses)
   at System.Net.Dns.<>c.b__27_2(Object s)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

虽然我在使用nordport服务时可以登录到rabbitmq管理仪表板。

这是我的 pod 规格

spec:
  containers:
    - name: rabbitmq
      image: rabbitmq:3-management-alpine
      # image name : tag
      ports:
        - containerPort: 5672
          name: amqp
        - containerPort: 15672
          name: http
      env:
        - name: RABBITMQ_DEFAULT_VHOST
          value: /
        - name: RABBITMQ_DEFAULT_USER
          value: dev
        - name: RABBITMQ_DEFAULT_PASS
          value: dev     

编辑 我在这里添加了我的服务文件

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-service
  labels:
    name: rabbitmq-service
    app: myapp
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: amqp
      protocol: TCP
      port: 5672
  selector:
    name: rabbitmq-pod
    app: myapp

问题出在 appsettings.json;尽管我将配置映射中的连接字符串提交到 appsettings.json,但应用程序正在从 apsetting.Development.json.

获取配置