【K8S基础】jconsole、jvisualvm等远程连接K8S java pod
【K8S基础】jconsole、jvisualvm等远程连接K8S java pod
·
Dockerfile
FROM openjdk:8-jdk-alpine
ENV TZ=Asia/Shanghai
RUN set -eux; \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
echo $TZ > /etc/timezone
ARG JAR_FILE="start-0.0.1-SNAPSHOT.jar"
ENV JAVA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=32767 -Dcom.sun.management.jmxremote.rmi.port=32767 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.222.101
VOLUME /tmp
COPY ${JAR_FILE} app.jar
EXPOSE 32767 8889
ENTRYPOINT java ${JAVA_OPTS} -jar /app.jar
192.168.222.101
为Master节点IP- NodePort暴露的端口需与
32767
一致
docker build --build-arg JAR_FILE=start-0.0.1-SNAPSHOT.jar -t zhangxueliang2020/jmx-test:0213 .
K8S:service
[root@m-0 ~]# kubectl get svc jmx-test -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2023-02-13T13:17:03Z"
labels:
app: jmx-test
name: jmx-test
namespace: default
resourceVersion: "784703613"
uid: 06546bc4-b46b-4909-847f-8363728fc0be
spec:
clusterIP: 10.102.213.230
clusterIPs:
- 10.102.213.230
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: jmx
nodePort: 32767
port: 32767
protocol: TCP
targetPort: 32767
- name: app
nodePort: 32089
port: 8889
protocol: TCP
targetPort: 8889
selector:
app: jmx-test
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
K8S:Deployment
[root@m-0 ~]# kubectl get deploy jmx-test -oyaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "10"
creationTimestamp: "2023-02-13T11:52:00Z"
generation: 10
labels:
app: jmx-test
name: jmx-test
namespace: default
resourceVersion: "783818165"
selfLink: /apis/apps/v1/namespaces/default/deployments/jmx-test
uid: 93e95d0f-13a0-4ff4-8216-6ba6a37b611f
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: jmx-test
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2023-02-13T23:27:38+08:00"
creationTimestamp: null
labels:
app: jmx-test
spec:
containers:
- image: zhangxueliang2020/jmx-test:0213
imagePullPolicy: Always
name: jmx-test
ports:
- containerPort: 32767
name: tcp-jmx
protocol: TCP
- containerPort: 8889
name: app
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2023-02-13T11:52:02Z"
lastUpdateTime: "2023-02-13T11:52:02Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2023-02-13T11:52:00Z"
lastUpdateTime: "2023-02-13T15:27:40Z"
message: ReplicaSet "jmx-test-556b8b7d88" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 10
readyReplicas: 1
replicas: 1
updatedReplicas: 1
更多推荐
已为社区贡献20条内容
所有评论(0)