版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/meifannao789456/article/details/82698286
为了简化jconsole的配置,我们使用无密码无认证,通过ip+port直接连接的方式。
1、在k8s页面的服务发现与负载均衡
中,配置对外开放的端口
"spec": {
"ports": [
{
"name": "http",
"protocol": "TCP",
"port": 8889,
"targetPort": 8889,
"nodePort": 31632
},
{
"name": "jconsole",
"protocol": "TCP",
"port": 31991,
"targetPort": 31991,
"nodePort": 31991
}
]
jconsole中的配置是我们开放连接用的端口。
2、在k8s的部署
中,配置服务启动参数
"env": [
{
"name": "OTHER_VM_OPTIONS",
"value": "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=31991 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.10.143 -Dcom.sun.management.jmxremote.rmi.port=31991"
}
]
这个value
中一般还有别的启动参数,我这里只写了jconsole配置所需要的。
注意:
hostname一定要写你的服务运行的服务器的ip。
port和你开放的端口号一致。