简体   繁体   English

在Kubernetes集群中的Rabbitmq

[英]Rabbitmq in Kubernetes cluster

I'm trying to do something very simple and it doesn't work. 我正在尝试做一些非常简单的事情而且它不起作用。 I must be doing something stupid but I just can't see it. 我必须做一些愚蠢的事情但我却看不到它。 I hope someone can... 我希望有人能......

When I run the rabbitmq:latest Docker image on my local docker I can connect to it successfully: 当我在rabbitmq:latest运行rabbitmq:latest Docker镜像时,我可以成功连接到它:

docker run -p 5672:5672 -d rabbitmq
telnet <dockerMachineIp> 5672
Trying x.y.z.w...
Connected to x.y.z.w.

Now I'm deploying the image into k8s: 现在我将图像部署到k8s:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    run: rabbitmq
  name: rabbitmq
  namespace: uat
spec:
  replicas: 1
  selector:
    matchLabels:
      env: uat
      run: rabbitmq
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        env: uat
        run: rabbitmq
    spec:
      containers:
      - image: rabbitmq
        imagePullPolicy: Always
        name: rabbitmq
        ports:
        - containerPort: 5672
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          tcpSocket:
            port: 5672
          initialDelaySeconds: 15
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        livenessProbe:
          failureThreshold: 3
          tcpSocket:
            port: 5672
          initialDelaySeconds: 15
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          limits:
            cpu: 100m
            memory: 150Mi
          requests:
            cpu: 100m
            memory: 150Mi
        terminationMessagePath: /dev/termination-log
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  observedGeneration: 2
  replicas: 1
  updatedReplicas: 1

And I create a service for it: 我为它创建了一个服务:

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  namespace: uat
spec:
  ports:
  - name: tcp5672
    port: 5672
    protocol: TCP
    targetPort: 5672
  selector:
    run: rabbitmq
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

The image successfully deploys: 图像成功部署:

2016-08-16T06:08:15.903787400Z =INFO REPORT==== 16-Aug-2016::06:08:15 ===
2016-08-16T06:08:15.903793115Z started TCP Listener on [::]:5672
2016-08-16T06:08:15.911128257Z  completed with 0 plugins.
2016-08-16T06:08:15.911479872Z 
2016-08-16T06:08:15.911492347Z =INFO REPORT==== 16-Aug-2016::06:08:15 ===
2016-08-16T06:08:15.911497759Z Server startup complete; 0 plugins started.
2016-08-16T06:11:00.901609310Z 

But after this my other application trying to connect to tcp://rabbitmq:5672 receive a Connection Refused . 但在此之后我的其他应用程序尝试连接到tcp://rabbitmq:5672接收Connection Refused When I test it myself: 当我自己测试时:

kubectl run --namespace uat -i --tty busybox --image=busybox --restart=Never -- sh
/ # telnet rabbitmq 5672
Connection closed by foreign host

In the rabbitmq logs I can see: 在rabbitmq日志中我可以看到:

2016-08-16T07:38:48.465296167Z =INFO REPORT==== 16-Aug-2016::07:38:48 ===
2016-08-16T07:38:48.465302171Z accepting AMQP connection <0.3666.0> (10.244.66.6:50968 -> 10.244.64.4:5672)
2016-08-16T07:38:48.465391749Z 
2016-08-16T07:38:48.465408673Z =ERROR REPORT==== 16-Aug-2016::07:38:48 ===
2016-08-16T07:38:48.465414738Z closing AMQP connection <0.3666.0> (10.244.66.6:50968 -> 10.244.64.4:5672):
2016-08-16T07:38:48.465420105Z {handshake_timeout,handshake}

What I'm doing here is so simple I don't see what I missed. 我在这里做的很简单,我看不出我错过了什么。

EDIT 编辑

I had left that issue on the side because I had no time to work on it. 我把这个问题留在了一边,因为我没时间研究它。 When I tried again a few weeks later it just started working. 几个星期后,当我再次尝试时,它才开始工作。 I didn't change the version of k8s or made any changes to the infrastructure. 我没有更改k8s的版本或对基础架构进行任何更改。 I'm afraid I don't know what happened 我怕我不知道发生了什么

5672 is the AMQP port is not accessible using HTTP . 5672是使用HTTP无法访问AMQP端口。

The management UI uses the port 15672 , but you have enable it: 管理UI使用端口15672 ,但您已启用它:

rabbitmq-plugins enable rabbitmq_management

see this https://www.rabbitmq.com/management.html 请参阅此https://www.rabbitmq.com/management.html

then you can use: http://server-name:15672/ 然后你可以使用: http:// server-name:15672 /

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

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