Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/easonlai/aks-java-alpine-openjdk-memory-dump

Taking Java Memory Dump from Containerized App running in AKS/K8S
https://github.com/easonlai/aks-java-alpine-openjdk-memory-dump

aks aks-kubernetes-cluster alpine alpine-image alpine-linux azure-kubernetes-service diagnostics docker docker-alpine java java-spring-boot javaspringboot jcmd jmap kubectl kubernetes kubernetes-cluster memory-dump tini

Last synced: about 1 month ago
JSON representation

Taking Java Memory Dump from Containerized App running in AKS/K8S

Awesome Lists containing this project

README

        

# Taking Java Memory Dump from Containerized App running in AKS/K8S

Special tricks to take Java memory dump from [Alpine](https://hub.docker.com/_/alpine) (e.g. [OpenJDK-Alpine](https://hub.docker.com/_/openjdk)) based container which running in [Azure Kubernetes Service (AKS)](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes). By adding [Tini](https://github.com/krallin/tini) as init of container, otherwise Java process in Alpine would be using PID 1 and would make "Unable to get pid of LinuxThreads manager thread" error when taking Java memory dump (same to [jcmd](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html), [jstack](https://docs.oracle.com/en/java/javase/13/docs/specs/man/jstack.html)).

* Dockerfile <-- Sample Dockerfile with Tini, it's using [openjdk:8-jdk-alpine](https://hub.docker.com/layers/openjdk/library/openjdk/8-jdk-alpine/images/sha256-210ecd2595991799526a62a7099718b149e3bbefdb49764cc2a450048e0dd4c0?context=explore).
* [Containerized App sample in Java Springboot](https://github.com/easonlai/serving-web-content-demo)

Get list of POD running in AKS.
```shell
kubectl get pod
```

Run interactive terminal from container POD.
```shell
kubectl exec -it your-java-app-pod-name /bin/sh
```

Check Process ID (PID) running Java.
PID not equal to 1 should be our target to take memory dump.
```shell
top
```

Start to take memory dump.
```shell
cd /tmp
jmap -dump:format=b,file=snapshot.jmap 1
exit
```

Copy out memory dump from container to your development machine.
```shell
kubectl cp your-java-app-pod-name:tmp/snapshot.jmap snapshot.jmap -n your-pod-namespace
```