簡體   English   中英

在Kubernetes集群中的Rabbitmq

[英]Rabbitmq in Kubernetes cluster

我正在嘗試做一些非常簡單的事情而且它不起作用。 我必須做一些愚蠢的事情但我卻看不到它。 我希望有人能......

當我在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.

現在我將圖像部署到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

我為它創建了一個服務:

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: {}

圖像成功部署:

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 

但在此之后我的其他應用程序嘗試連接到tcp://rabbitmq:5672接收Connection Refused 當我自己測試時:

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

在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}

我在這里做的很簡單,我看不出我錯過了什么。

編輯

我把這個問題留在了一邊,因為我沒時間研究它。 幾個星期后,當我再次嘗試時,它才開始工作。 我沒有更改k8s的版本或對基礎架構進行任何更改。 我怕我不知道發生了什么

5672是使用HTTP無法訪問AMQP端口。

管理UI使用端口15672 ,但您已啟用它:

rabbitmq-plugins enable rabbitmq_management

請參閱此https://www.rabbitmq.com/management.html

然后你可以使用: http:// server-name:15672 /

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM