配置ActiveMQ Artemis Operator控制台以支持Jolokia外部访问
解决Minikube中ActiveMQ Artemis Jolokia无重启访问问题
问题场景
在Minikube中运行ArtemisCloud的ActiveMQ Artemis Operator,集群运行正常,但需从外部监控Jolokia服务。按文档配置ActiveMQArtemis资源后,Jolokia未按预期可访问:
配置内容:
apiVersion: broker.amq.io/v1beta1 kind: ActiveMQArtemis metadata: name: artemis-broker spec: deploymentPlan: enableMetricsPlugin: true console: expose: true ingressHost: myhost.local
Pod内配置异常点:
bootstrap.xml仅绑定集群内部FQDN,未监听本地网卡:
<binding sniHostCheck="false" sniRequired="false" name="artemis" uri="http://artemis-broker-ss-0.artemis-broker-hdls-svc.activemq-artemis-operator.svc.cluster.local:8161">
jolokia-access.xml仅允许该内部FQDN的请求:
<allow-origin>*://artemis-broker-ss-0.artemis-broker-hdls-svc.activemq-artemis-operator.svc.cluster.local*</allow-origin>
Pod内访问测试失败:
sh-4.4$ curl http://localhost:8161/console/jolokia curl: (7) Failed to connect to localhost port 8161: Connection refused sh-4.4$ curl http://$(hostname -f):8161/console/jolokia # 无响应 sh-4.4$ curl http://artemis-broker-ss-0.artemis-broker-hdls-svc.activemq-artemis-operator.svc.cluster.local:8161/console/jolokia # 无响应
需在不重启Pod的前提下修复访问问题。
官方无重启修复步骤
1. 修改控制台绑定地址
将bootstrap.xml中的监听地址改为0.0.0.0(监听所有网卡):
kubectl exec -it artemis-broker-ss-0 -- sed -i 's/uri="http:\/\/artemis-broker-ss-0.artemis-broker-hdls-svc.activemq-artemis-operator.svc.cluster.local:8161"/uri="http:\/\/0.0.0.0:8161"/' /home/jboss/broker/etc/bootstrap.xml
2. 更新Jolokia访问控制允许源
添加localhost和外部访问域名myhost.local到允许列表:
kubectl exec -it artemis-broker-ss-0 -- sed -i '/<allow-origin>/a <allow-origin>*://localhost*</allow-origin>' /home/jboss/broker/etc/jolokia-access.xml kubectl exec -it artemis-broker-ss-0 -- sed -i '/<allow-origin>/a <allow-origin>*://myhost.local*</allow-origin>' /home/jboss/broker/etc/jolokia-access.xml
3. 热重载Artemis配置
执行内置命令触发配置重载,无需重启Pod:
kubectl exec -it artemis-broker-ss-0 -- /home/jboss/broker/bin/artemis reload
4. 验证Pod内部访问
再次测试本地访问:
kubectl exec -it artemis-broker-ss-0 -- curl http://localhost:8161/console/jolokia
此时应返回Jolokia的标准JSON响应。
5. 外部访问验证(Minikube环境)
将myhost.local映射到Minikube节点IP:
echo "$(minikube ip) myhost.local" | sudo tee -a /etc/hosts
之后在本地通过http://myhost.local/console/jolokia即可访问Jolokia服务。
内容的提问来源于stack exchange,提问作者djb
相关产品推荐
相关产品推荐

