I'm trying to run jmx on ocp. I've set all required parameters in my container. When creating a container, I set the environment variables:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.rmi.port=1099
-Djava.rmi.server.hostname=127.0.0.1
When I try to connect to my service (using service IP or hostname) - I get connection refused:
IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: service.namespace-18569.svc
After a few attempts, I tried to check JMX endpoint using curl -I.
After checking in pod terminal (curl -I 127.0.0.1:JMXPORT/Endpoint
) I get a response from the JMX server.
Unfortunately when I tried to use curl -I
with service IP/Hostname (in the same pod terminal) - I get connection refused.
Is it possible to make a JMX connection between different pods using IP service?
EDIT:
My deployment config:
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
creationTimestamp: '2019-02-06T17:11:36Z'
generation: 1
labels:
app: napeOfApp
name: napeOfApp
namespace: nameOfMynamespace
resourceVersion: '202879946'
selfLink: /apis/apps.openshift.io/v1/namespaces/nameOfMynamespace/deploymentconfigs/napeOfApp
uid: 42606226-2a32-11e9-9b9a-02e3ccdc5484
spec:
replicas: 1
revisionHistoryLimit: 3
selector:
deploymentconfig: napeOfApp
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
creationTimestamp: null
labels:
app: napeOfApp
deploymentconfig: napeOfApp
name: napeOfApp
spec:
containers:
- image: 'my image repo'
imagePullPolicy: IfNotPresent
name: napeOfApp
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 3084 //(JMX PORT)
protocol: TCP
- containerPort: 3104
protocol: TCP
- containerPort: 7005
protocol: TCP
- containerPort: 8443
protocol: TCP
resources:
limits:
cpu: '1'
memory: 3584Mi
requests:
cpu: 500m
memory: 2560Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
test: false
triggers:
- type: ConfigChange
status:
availableReplicas: 1
conditions:
- lastTransitionTime: '2019-02-06T17:11:41Z'
lastUpdateTime: '2019-02-06T17:11:41Z'
message: Deployment config has minimum availability.
status: 'True'
type: Available
- lastTransitionTime: '2019-02-06T17:11:42Z'
lastUpdateTime: '2019-02-06T17:11:42Z'
message: replication controller "napeOfApp" successfully rolled out
reason: NewReplicationControllerAvailable
status: 'True'
type: Progressing
details:
causes:
- type: ConfigChange
message: config change
latestVersion: 1
observedGeneration: 1
readyReplicas: 1
replicas: 1
unavailableReplicas: 0
updatedReplicas: 1
3084 is JMX port.
I'd guess, if you are seeing a connection refused error, that the service port is wrong. The reason is that "connection refused" itself means that the port isn't even open at all.
So, your probably just trying to access the service on the wrong IP.
This happens when, for example, you try to access a service port on a host IP. Remember, the service port is internal to the cluster, whereas the host port will expose this port on a (typically 5 digit) port.
To figure out, do oc get svc -o wide
and look at the node port that your service is bound on.
Is it possible to make a JMX connection between different pods using IP service?
Yes, it should work seamlessly, either using the service IP address or the service name according to how DNS works in K8s.
Looks like the problem for you is this:
-Djava.rmi.server.hostname=127.0.0.1
This is basically binding to 127.0.0.1
only and allowing only local connections. You might want to try 0.0.0.0
so that external connections are allowed.
Hope it helps!