无法从另一个Pod K8s连接RabbitMQ Pod

时间:2020-08-12 08:53:52

标签: kubernetes rabbitmq pod

我目前正在尝试部署一个应用程序来连接Rabbitmq。

应用程序和Rabbitmq位于同一群集节点上的不同容器中。

我无法通过服务名或群集IP连接到RabbitMQ。

您对这个问题有任何想法吗?

对应用程序的认知

None of the specified endpoints were reachable

这是Rabbitmq_deployment.yaml

 apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: rabbitmq
   namespace: test
 spec:
   selector:
     matchLabels:
       run: rabbitmq
   replicas: 1
   template:
     metadata:
       labels:
         run: rabbitmq
     spec:
       containers:
       - name: rabbitmq
         image: rabbitmq_delay_v3.7
         imagePullPolicy: IfNotPresent
 ---
 apiVersion: v1
 kind: Service
 metadata:
   name: rabbitmq-svc
   namespace: test
   labels:
     run: rabbitmq
 spec:
   type: NodePort
   ports:
   - name: rabbit-web
     protocol: TCP
     port: 15672
     targetPort: 15672
     nodePort: 30000
   - name: rabbit-svc
     protocol: TCP
     port: 5672
     targetPort: 5672
   selector:
     run: rabbitmq

这是app_deployment.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: app_test
      namespace: test
    spec:
      selector:
        matchLabels:
          run: app_test
      replicas: 1
      template:
        metadata:
          labels:
            run: app_test
        spec:
          containers:
          - name: app1
            image: my_app_image
            imagePullPolicy: IfNotPresent
            env:
              - name: "ASPNETCORE_ENVIRONMENT"
                value: "Staging"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: app-test-svc
      namespace: test
      labels:
        run: app-test
    spec:
      type: NodePort
      ports:
      - name: app_test_port
        protocol: TCP
        port: 80
        targetPort: 80
        nodePort: 30203
      selector:
        run: app_test

这是在应用程序上连接Rabbitmq的配置

"QueueConfig": {
        "HostName": "rabbitmq-svc",
        "UserName": "guest",
        "Pwd": "guest",
        "VirtualHost": "/",
        "Port": 5672,
}

这里是kubectl -n test describe avc rabbitmq-svc

的输出
  Name:                     rabbitmq-svc
  Namespace:                test
  Labels:                   run=rabbitmq
  Annotations:              Selector:  run=rabbitmq
  Type:                     NodePort
  IP:                       10.103.189.233
  Port:                     rabbit-web  15672/TCP
  TargetPort:               15672/TCP
  NodePort:                 rabbit-web  30000/TCP
  Endpoints:                10.244.1.174:15672
  Port:                     rabbit-svc  5672/TCP
  TargetPort:               5672/TCP
  NodePort:                 rabbit-svc  31425/TCP
  Endpoints:                10.244.1.174:5672
  Session Affinity:         None
  External Traffic Policy:  Cluster
  Events:                   <none>

这里是kubectl get pods -n kube-system

的输出
NAME                                  READY   STATUS    RESTARTS   AGE
coredns-66bff467f8-j8494              1/1     Running   1          7d9h
coredns-66bff467f8-jtn5w              1/1     Running   1          7d9h
etcd-master-node                      1/1     Running   1          7d9h
kube-apiserver-master-node            1/1     Running   1          7d9h
kube-controller-manager-master-node   1/1     Running   1          7d9h
kube-flannel-ds-amd64-8gd7b           1/1     Running   1          7d9h
kube-flannel-ds-amd64-xj2hw           1/1     Running   1          7d8h
kube-proxy-62wsz                      1/1     Running   1          7d9h
kube-proxy-77g2d                      1/1     Running   0          7d8h
kube-scheduler-master-node            1/1     Running   1          7d9h

0 个答案:

没有答案