Unable to debug java app through stack driver in google kubernetes cluster

11/8/2019

I am trying to debug a java app on GKE cluster through stack driver. I have created a GKE cluster with Allow full access to all Cloud APIs I am following documentation: https://cloud.google.com/debugger/docs/setup/java

Here is my DockerFile:

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} alnt-watchlist-microservice.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/alnt-watchlist-microservice.jar"]

In documentation, it was written to add following lines in DockeFile:

RUN  mkdir /opt/cdbg && \
     wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | \
     tar xvz -C /opt/cdbg

RUN java -agentpath:/opt/cdbg/cdbg_java_agent.so 
    -Dcom.google.cdbg.module=tpm-watchlist
    -Dcom.google.cdbg.version=v1
    -jar /alnt-watchlist-microservice.jar

When I build DockerFile, It fails saying tar: invalid magic , tar: short read.

In stackdriver debug console, It always show 'No deployed application found'. Which application it will show? I have already 2 services deployed on my kubernetes cluster.

I have already executed gcloud debug source gen-repo-info-file --output-directory="WEB-INF/classes/ in my project's directory.

It generated source-context.json. After its creation, I tried building docker image and its failing.

-- Roobal Jindal
google-cloud-debugger
google-cloud-stackdriver
google-kubernetes-engine
kubernetes
stackdriver

3 Answers

12/2/2019

I resolved the issue.

Firstly, you will have to use java image "gcr.io/google-appengine/openjdk" instead of Alpine one.

Secondly, I was putting entry points without comma separated (Basically in wrong format)

ENTRYPOINT ["java","-agentpath:/opt/cdbg/cdbg_java_agent.so", "-Djava.security.egd=file:/dev/./urandom"  ,"-Dcom.google.cdbg.module=watchlist"]
-- Roobal Jindal
Source: StackOverflow

11/11/2019

The debugger will be ready for use when you deploy your containerized app. You are getting No deployed application found error because your debugger agent is failing to download or unzip in dockerfile.

Please check this discussion to resolve the tar: invalid magic , tar: short read. error.

-- MR.K
Source: StackOverflow

11/20/2019

Unfortunately it looks like Alpine isn't regularly tested with Debugger. There's a sample setup here that might help you: https://github.com/GoogleCloudPlatform/cloud-debug-java#alpine-linux

-- wjg
Source: StackOverflow