Java remote debugging of applications running on Kubernetes
Article by the only cloud technology translation, if reproduced, must be marked reproduced from the "only cloud technology"
Kubernetes1.2 version has just recently released to become a container (Docker, Rocket, Hyper, etc., the fact that the cluster management path. Here are some interesting features on the 1.2 version:
Clusters can now scale to 30,000 containers A cluster of elegant closed nodes, transition to other nodes running in the cluster Customize the specified indicators as the basis for automatic expansion of dynamic configuration management When you develop micro services on top of the local notebook, you You can use Kubernetes to run your local Docker container and get a similar process such as developer / QA / production process when you configure your application.
For Java developers, there is one thing that will happen: how you look at the log, do remote debugging, and how to track the protocol stack. The following article is a few tips:
Track logs for your pod
In some cluster management systems, you basically have to find the application's local IP (if it is running in the container), in any case to ssh to it, and then find the log and track it. With Kubernetes, you do not have to do anything above. In addition to the machine you are running (that is where you run Kubernetes client), you can follow the following:
List the following pods in your cluster
Tracking the log <br /> Now select the log you want to track and run it!
If necessary, connect through the shell
If you have to log in to the pod for some reason (look at the file system, see other configuration files, etc.)
The virtual machine remotely debugs your application
In this case, it would be convenient to see what happened to your application. In order to do this, you just do the same thing as you do today. When you bootstrap your JVM, you should have a way to start JVM debugging. For example, the HawtApp Maven plugin is a simple mvn plugin that makes Java Main an executable, simple, and flexible bootrtrap bin / run.sh script (or windows batch file) that allows you to control paths and pass environment variables debugging
Bootstrap Java can be exposed to the debug port
Define the debug port in the docker container via the Kubernetes key list
Now you need to expose port 5005 (in this example) in your Docker container via your Kubernetes key list (json / yaml)
Note that we have added an env variable to the Kubernetes key list file to control whether we want to remotely debug open or close (true / false). The Bootstrap script (described above) checks the env variable, and you can control it via the kube key list (now Kube1.2 has ConfigMap, or OpenShift templates).
The last step is to proxy the service port to your local machine. If you run kubectlclient locally, it will be very easy:
List the pods in the cluster
Proxy pod to a special port
The above code will be forwarded from your local environment (5005) port to pod port 5005. Now you can attach your remote debugger to localhost: 5005.
Hope this post can help you debug your Java apps!
Repeat it, the article by the cloud technology translation, if reproduced, must be marked reproduced from the "only cloud technology"
Original link: http://blog.christianposta.com … 1bb5f
To find out more about Kubernetes, please pay attention to the Caicloud public platform