我试图做一些非常简单的事情并且它不起作用。我必须做一些愚蠢的事情,但我无法看到它。我希望有人可以......
当我在本地docker上运行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的版本或对基础架构进行任何更改。我怕我不知道发生了什么
答案 0 :(得分:0)
5672
是无法使用HTTP
访问AMQP端口。
管理UI使用端口15672
,但您已启用它:
rabbitmq-plugins enable rabbitmq_management
请参阅此https://www.rabbitmq.com/management.html
然后你可以使用:http://server-name:15672/