如何远程调试k8s里的jettypod

时间:2022-12-12 13:59:27


 

课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。

介绍主要的k8s资源的使用配置和命令。包括configmap,pod,service,replicaset,namespace,deployment,daemonset,ingress,pv,pvc,sc,role,rolebinding,clusterrole,clusterrolebinding,secret,serviceaccount,statefulset,job,cronjob,podDisruptionbudget,podSecurityPolicy,networkPolicy,resourceQuota,limitrange,endpoint,event,conponentstatus,node,apiservice,controllerRevision等。

详细介绍helm命令,学习helm chart语法,编写helm chart。深入分析各项目源码,学习编写helm插件
————————————————

#===========================================================
# Jetty start.jar arguments
# Each line of this file is prepended to the command line
# arguments # of a call to:
# java -jar start.jar [arg...]
#===========================================================



#===========================================================
# If the arguements in this file include JVM arguments
# (eg -Xmx512m) or JVM System properties (eg com.sun.???),
# then these will not take affect unless the --exec
# parameter is included or if the output from --dry-run
# is executed like:
# eval $(java -jar start.jar --dry-run)
#
# Below are some recommended options for Sun's JRE
#-----------------------------------------------------------
--exec
# -Dorg.apache.jasper.compiler.disablejsr199=true
# -Dcom.sun.management.jmxremote
# -Dorg.eclipse.jetty.util.log.IGNORED=true
# -Dorg.eclipse.jetty.LEVEL=DEBUG
# -Dorg.eclipse.jetty.util.log.stderr.SOURCE=true
-server
-verbose:gc
-Xms1024m
-Xmx1024m
-Xmn512m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:ParallelGCThreads=1
-Djava.security.egd=file:/dev/./urandom
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Djava.awt.headless=true
-Djava.net.preferIPv4Stack=true
-Dsun.net.client.defaultConnectTimeout=10000
-Dsun.net.client.defaultReadTimeout=30000
-Djava.net.preferIPv4Stack=true
#-Xloggc:../logs/gc.log
# -XX:+PrintGCTimeStamps
# -XX:+PrintTenuringDistribution
# -XX:+PrintCommandLineFlags
# -XX:+DisableExplicitGC
# -XX:+UseConcMarkSweepGC
# -XX:ParallelCMSThreads=2
# -XX:+CMSClassUnloadingEnabled
# -XX:+UseCMSCompactAtFullCollection
# -XX:CMSInitiatingOccupancyFraction=80
#-----------------------------------------------------------

-Xdebug
-Xrunjdwp:transport=dt_socket,address=26666,server=y,suspend=n
#===========================================================
# Start classpath OPTIONS.
# These control what classes are on the classpath
# for a full listing do
# java -jar start.jar --list-options
#-----------------------------------------------------------
#OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations
OPTIONS=Server,jsp
#-----------------------------------------------------------


#===========================================================
# Configuration files.
# For a full list of available configuration files do
# java -jar start.jar --help
#-----------------------------------------------------------
#etc/jetty-jmx.xml
#etc/jetty.xml
## etc/jetty-annotations.xml
# etc/jetty-ssl.xml
# etc/jetty-requestlog.xml
#etc/jetty-deploy.xml
#etc/jetty-overlay.xml
#etc/jetty-webapps.xml
#etc/jetty-contexts.xml
## etc/jetty-testrealm.xml
#===========================================================

修改jetty.ini配置文件加上:

 

-Xdebug
-Xrunjdwp:transport=dt_socket,address=26666,server=y,suspend=n

26666是调试端口.

创建一个nodePort类型的service

apiVersion: v1
kind: Service
metadata:
creationTimestamp: 2018-05-07T12:13:23Z
labels:
app: liward
name: liward-web
namespace: dev-app
resourceVersion: "1980618"
selfLink: /api/v1/namespaces/dev-app/services/liward-web
uid: 09b7cd71-51f0-11e8-8c57-002197403677
spec:
clusterIP: 10.103.193.113
externalTrafficPolicy: Cluster
ports:
- name: http
nodePort: 32730
port: 8080
protocol: TCP
targetPort: 8080
- name: debug
nodePort: 30001
port: 26666
protocol: TCP
targetPort: 26666
selector:
app: liward
sessionAffinity: None
type: NodePort
status:
loadBalancer: {

看到targetPort和调试端口一致。

30001为客户端连接调试端口。

然后就可以用hostIp+30001调试pod里的容器了