Kubernetes Java 远程 Debug 添加配置

Debug Kubernetes Java About 497 words

Deployment 配置

containers.env下添加环境变量JDK_JAVA_OPTIONS。重启Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-service
  namespace: my-ns
spec:
  replicas: 1
  template:
    spec:
      containers:
        - env:
            - name: JDK_JAVA_OPTIONS
              value: >-
                -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005

端口转发

kubectl port-forward pod-name 5005:5005

环境变量区别

Java 11使用JDK_JAVA_OPTIONSJava 8使用JAVA_OPTIONS(较新版本也兼容JDK_JAVA_OPTIONS

Views: 483 · Posted: 2024-07-29

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh