GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
320 stars 59 forks source link

Breakpoints not hit in Java app deployed to GKE #3010

Closed nicopoirier closed 3 years ago

nicopoirier commented 3 years ago

I'm trying to debug java-hello-world from here with docker.io. The project is build and deploy, the url is ok and the application is running, the panel Debug is launch but the panel Debug(5005) is never launch and no portForward to the 5005. I can't debug the application

Skaffold.yaml

kind: Config
build:
  artifacts:
    - image: java-hello-world
      context: .
      kaniko: {}
  tagPolicy:
    sha256: {}
  cluster:
    dockerConfig:
      secretName: kaniko-secret
    namespace: kaniko-build
deploy:
  kubectl:
    manifests:
      - ./kubernetes-manifests/*.service.yaml
      - ./kubernetes-manifests/*.deployment.yaml

the Dockerfile

FROM  maven:3-jdk-11-slim  AS build-env
WORKDIR /app
COPY pom.xml ./
RUN mvn verify --fail-never
COPY . ./
RUN mvn -Dmaven.test.skip=true package
FROM openjdk:11-jre-slim
COPY --from=build-env /app/target /app/
CMD ["java", "-jar", "/app/hello-world-1.0.0.jar"]

After deploy the describe from the pod

Name:         java-hello-world-6895b55468-ngp5q
Namespace:    default
Priority:     0
Node:         gke-origin-demo-default-pool-c59caac2-5lh6/10.132.0.52
Start Time:   Wed, 20 Oct 2021 22:01:42 +0000
Labels:       app=java-hello-world
              ide=Idea
              ideVersion=2021.2.2.0.0
              ijPluginVersion=21.10.1
              pod-template-hash=6895b55468
              skaffold.dev/run-id=d44980f6-f1a8-40dd-9ac2-03c15f0581d1
Annotations:  <none>
Status:       Running
IP:           10.108.4.87
IPs:
  IP:           10.108.4.87
Controlled By:  ReplicaSet/java-hello-world-6895b55468
Containers:
  server:
    Container ID:   containerd://b2903855243428d7398d301a0e04f80aeae3da96fd434f8b578fbfe204fa50cd
    Image:          nicopoirier/java-hello-world:latest
    Image ID:       docker.io/nicopoirier/java-hello-world@sha256:8fc11959a2eec532f567b8f0299d15f8fe67b6d0fd273cbb9580014b847cf2f4
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Wed, 20 Oct 2021 22:01:47 +0000
    Ready:          True
    Restart Count:  0
    Readiness:      tcp-socket :8080 delay=5s timeout=1s period=10s #success=1 #failure=3
    Environment:
      PORT:  8080
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-zjk6g (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-zjk6g:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-zjk6g
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>

image

Expected Behavior

Will be able to remote debug with Kubernetes

Actual Behavior

The debug mode is not launch

Additional Information

The full log

Validating Kubernetes dependencies...
Validating image repository settings...

Input image registry 'docker.io/nicopoirier' does not match the expected image repo of 'gcr.io/origin-demo' based on the GCP project associated with the current context 'gke_origin-demo_europe-west1_origin-demo'
Please ensure that the cluster is authorized to pull images from the input registry, or update the container image field in the run configuration.

/usr/bin/skaffold debug --filename skaffold.yaml --label ide=Idea --label ideVersion=2021.2.2.0.0 --label ijPluginVersion=21.9.2 --default-repo docker.io/nicopoirier --rpc-port 50051 --port-forward=true --wait-for-deletions-max=2m0s --status-check=true --enable-rpc=true --verbosity trace
starting gRPC server on port 50051
Skaffold &{Version:v1.33.0 ConfigVersion:skaffold/v2beta24 GitVersion: GitCommit:251c0406b3f9ef149cfa084d912874fd080e1e97 BuildDate:2021-10-07T19:30:49Z GoVersion:go1.14.14 Compiler:gc Platform:linux/amd64 User:}
Loaded Skaffold defaults from "/usr/local/google/home/npoirier/.skaffold/config"
Skipping update check for flag `--update-check` set to false
config version out of date: upgrading to latest "skaffold/v2beta24"
config version out of date: upgrading to latest "skaffold/v2beta24"
parsed 1 configs from configuration file /usr/local/google/home/npoirier/source/origin/demo-guestbook/cloud-code-samples/java/java-hello-world/skaffold.yaml
validating yamltags of struct SkaffoldConfig
validating yamltags of struct Metadata
validating yamltags of struct Pipeline
config version out of date: upgrading to latest "skaffold/v2beta24"
validating yamltags of struct BuildConfig
validating yamltags of struct Artifact
validating yamltags of struct ArtifactType
validating yamltags of struct KanikoArtifact
validating yamltags of struct BuildHooks
validating yamltags of struct TagPolicy
validating yamltags of struct ShaTagger
validating yamltags of struct BuildType
validating yamltags of struct ClusterDetails
validating yamltags of struct DockerConfig
validating yamltags of struct DeployConfig
validating yamltags of struct DeployType
validating yamltags of struct KubectlDeploy
validating yamltags of struct KubectlFlags
validating yamltags of struct DeployHooks
validating yamltags of struct LogsConfig
Using kubectl context: gke_origin-demo_europe-west1_origin-demo
Running command: [minikube version --output=json]
Command output: [{"commit":"0a0ad764652082477c00d51d2475284b5d39ceed","minikubeVersion":"v1.23.2"}
]
Running command: [/usr/local/google/home/npoirier/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/bin/minikube profile list -o json --user=skaffold]
Command output: [{"invalid":[],"valid":[{"Name":"minikube","Status":"Unknown","Config":{"Name":"minikube","KeepContext":false,"EmbedCerts":false,"MinikubeISO":"","KicBaseImage":"gcr.io/k8s-minikube/kicbase:v0.0.27@sha256:89b4738ee74ba28684676e176752277f0db46f57d27f0e08c3feec89311e22de","Memory":16000,"CPUs":2,"DiskSize":20000,"VMDriver":"","Driver":"docker","HyperkitVpnKitSock":"","HyperkitVSockPorts":[],"DockerEnv":null,"ContainerVolumeMounts":null,"InsecureRegistry":null,"RegistryMirror":[],"HostOnlyCIDR":"192.168.99.1/24","HypervVirtualSwitch":"","HypervUseExternalSwitch":false,"HypervExternalAdapter":"","KVMNetwork":"default","KVMQemuURI":"qemu:///system","KVMGPU":false,"KVMHidden":false,"KVMNUMACount":1,"DockerOpt":null,"DisableDriverMounts":false,"NFSShare":[],"NFSSharesRoot":"/nfsshares","UUID":"","NoVTXCheck":false,"DNSProxy":false,"HostDNSResolver":true,"HostOnlyNicType":"virtio","NatNicType":"virtio","SSHIPAddress":"","SSHUser":"root","SSHKey":"","SSHPort":22,"KubernetesConfig":{"KubernetesVersion":"v1.22.2","ClusterName":"minikube","Namespace":"default","APIServerName":"minikubeCA","APIServerNames":null,"APIServerIPs":null,"DNSDomain":"cluster.local","ContainerRuntime":"docker","CRISocket":"","NetworkPlugin":"","FeatureGates":"","ServiceCIDR":"10.96.0.0/12","ImageRepository":"","LoadBalancerStartIP":"","LoadBalancerEndIP":"","CustomIngressCert":"","ExtraOptions":null,"ShouldLoadCachedImages":true,"EnableDefaultCNI":false,"CNI":"","NodeIP":"","NodePort":8443,"NodeName":""},"Nodes":[{"Name":"","IP":"","Port":8443,"KubernetesVersion":"v1.22.2","ControlPlane":true,"Worker":true}],"Addons":null,"CustomAddonImages":null,"CustomAddonRegistries":null,"VerifyComponents":{"apiserver":true,"system_pods":true},"StartHostTimeout":360000000000,"ScheduledStop":null,"ExposedPorts":[],"ListenAddress":"","Network":"","MultiNodeRequested":false,"ExtraDisks":0}}]}]
Minikube cluster not detected for context "gke_origin-demo_europe-west1_origin-demo"
Running command: [/usr/local/google/home/npoirier/.cache/google-cloud-tools-java/managed-cloud-sdk/LATEST/google-cloud-sdk/bin/minikube profile list -o json --user=skaffold]
Command output: [{"invalid":[],"valid":[{"Name":"minikube","Status":"Unknown","Config":{"Name":"minikube","KeepContext":false,"EmbedCerts":false,"MinikubeISO":"","KicBaseImage":"gcr.io/k8s-minikube/kicbase:v0.0.27@sha256:89b4738ee74ba28684676e176752277f0db46f57d27f0e08c3feec89311e22de","Memory":16000,"CPUs":2,"DiskSize":20000,"VMDriver":"","Driver":"docker","HyperkitVpnKitSock":"","HyperkitVSockPorts":[],"DockerEnv":null,"ContainerVolumeMounts":null,"InsecureRegistry":null,"RegistryMirror":[],"HostOnlyCIDR":"192.168.99.1/24","HypervVirtualSwitch":"","HypervUseExternalSwitch":false,"HypervExternalAdapter":"","KVMNetwork":"default","KVMQemuURI":"qemu:///system","KVMGPU":false,"KVMHidden":false,"KVMNUMACount":1,"DockerOpt":null,"DisableDriverMounts":false,"NFSShare":[],"NFSSharesRoot":"/nfsshares","UUID":"","NoVTXCheck":false,"DNSProxy":false,"HostDNSResolver":true,"HostOnlyNicType":"virtio","NatNicType":"virtio","SSHIPAddress":"","SSHUser":"root","SSHKey":"","SSHPort":22,"KubernetesConfig":{"KubernetesVersion":"v1.22.2","ClusterName":"minikube","Namespace":"default","APIServerName":"minikubeCA","APIServerNames":null,"APIServerIPs":null,"DNSDomain":"cluster.local","ContainerRuntime":"docker","CRISocket":"","NetworkPlugin":"","FeatureGates":"","ServiceCIDR":"10.96.0.0/12","ImageRepository":"","LoadBalancerStartIP":"","LoadBalancerEndIP":"","CustomIngressCert":"","ExtraOptions":null,"ShouldLoadCachedImages":true,"EnableDefaultCNI":false,"CNI":"","NodeIP":"","NodePort":8443,"NodeName":""},"Nodes":[{"Name":"","IP":"","Port":8443,"KubernetesVersion":"v1.22.2","ControlPlane":true,"Worker":true}],"Addons":null,"CustomAddonImages":null,"CustomAddonRegistries":null,"VerifyComponents":{"apiserver":true,"system_pods":true},"StartHostTimeout":360000000000,"ScheduledStop":null,"ExposedPorts":[],"ListenAddress":"","Network":"","MultiNodeRequested":false,"ExtraDisks":0}}]}]
Minikube cluster not detected for context "gke_origin-demo_europe-west1_origin-demo"
setting Docker user agent to skaffold-v1.33.0
Using builder: cluster
build concurrency first set to 0 parsed from *cluster.Builder[0]
final build concurrency value is 0
Listing files to watch...
 - java-hello-world
Checking base image maven:3-jdk-11-slim for ONBUILD triggers.
Checking base image openjdk:11-jre-slim for ONBUILD triggers.
Found dependencies for dockerfile: [{pom.xml /app true} {. /app true}]
Skipping excluded path: .idea
Skipping excluded path: .readmes
Skipping excluded path: .vscode
Skipping excluded path: .dockerignore
List generated in 1.272 second
Generating tags...
 - java-hello-world -> docker.io/nicopoirier/java-hello-world:latest
Tags generated in 179.685µs
Checking cache...
 - java-hello-world: Found. Tagging
attempting to add tag docker.io/nicopoirier/java-hello-world:latest to src docker.io/nicopoirier/java-hello-world:latest@sha256:cc20c951996e9642ca69e57e9a4cf192712b5459d6ad1ac65bd6d72c2c6de910
Cache check completed in 2.625 seconds
Tags used in deployment:
 - java-hello-world -> docker.io/nicopoirier/java-hello-world:latest@sha256:cc20c951996e9642ca69e57e9a4cf192712b5459d6ad1ac65bd6d72c2c6de910
Starting deploy...
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
Running command: [kubectl version --client -ojson]
Command output: [{
  "clientVersion": {
    "major": "1",
    "minor": "22",
    "gitVersion": "v1.22.2",
    "gitCommit": "8b5a19147530eaac9476b0ab82980b4088bbc1b2",
    "gitTreeState": "clean",
    "buildDate": "2021-09-15T21:38:50Z",
    "goVersion": "go1.16.8",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}
]
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo create --dry-run=client -oyaml -f /usr/local/google/home/npoirier/source/origin/demo-guestbook/cloud-code-samples/java/java-hello-world/kubernetes-manifests/hello.service.yaml -f /usr/local/google/home/npoirier/source/origin/demo-guestbook/cloud-code-samples/java/java-hello-world/kubernetes-manifests/hello.deployment.yaml]
Command output: [apiVersion: v1
kind: Service
metadata:
  name: java-hello-world-external
  namespace: default
spec:
  ports:
  - name: http
    port: 80
    targetPort: 8080
  selector:
    app: java-hello-world
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: java-hello-world
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: java-hello-world
  template:
    metadata:
      labels:
        app: java-hello-world
    spec:
      containers:
      - env:
        - name: PORT
          value: "8080"
        - name: JAVA_TOOL_OPTIONS
          value: -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y
        image: nicopoirier/java-hello-world:latest
        name: server
        ports:
        - containerPort: 8080
        readinessProbe:
          initialDelaySeconds: 5
          tcpSocket:
            port: 8080
      imagePullSecrets:
      - name: regreadsecret
]
image [java-hello-world] is not used by the current deployment
manifests with tagged images:apiVersion: v1
kind: Service
metadata:
  name: java-hello-world-external
  namespace: default
spec:
  ports:
  - name: http
    port: 80
    targetPort: 8080
  selector:
    app: java-hello-world
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: java-hello-world
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: java-hello-world
  template:
    metadata:
      labels:
        app: java-hello-world
    spec:
      containers:
      - env:
        - name: PORT
          value: "8080"
        - name: JAVA_TOOL_OPTIONS
          value: -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y
        image: nicopoirier/java-hello-world:latest
        name: server
        ports:
        - containerPort: 8080
        readinessProbe:
          initialDelaySeconds: 5
          tcpSocket:
            port: 8080
      imagePullSecrets:
      - name: regreadsecret
no debug transformation for: service/java-hello-world-external
skipping probe rewrite on "": not configured for debugging
manifests with labels apiVersion: v1
kind: Service
metadata:
  labels:
    ide: Idea
    ideVersion: 2021.2.2.0.0
    ijPluginVersion: 21.9.2
    skaffold.dev/run-id: b4fc0f83-8801-40aa-8132-451fc18bd98f
  name: java-hello-world-external
  namespace: default
spec:
  ports:
  - name: http
    port: 80
    targetPort: 8080
  selector:
    app: java-hello-world
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    ide: Idea
    ideVersion: 2021.2.2.0.0
    ijPluginVersion: 21.9.2
    skaffold.dev/run-id: b4fc0f83-8801-40aa-8132-451fc18bd98f
  name: java-hello-world
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: java-hello-world
  template:
    metadata:
      labels:
        app: java-hello-world
        ide: Idea
        ideVersion: 2021.2.2.0.0
        ijPluginVersion: 21.9.2
        skaffold.dev/run-id: b4fc0f83-8801-40aa-8132-451fc18bd98f
    spec:
      containers:
      - env:
        - name: PORT
          value: "8080"
        - name: JAVA_TOOL_OPTIONS
          value: -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y
        image: nicopoirier/java-hello-world:latest
        name: server
        ports:
        - containerPort: 8080
        readinessProbe:
          initialDelaySeconds: 5
          tcpSocket:
            port: 8080
      imagePullSecrets:
      - name: regreadsecret
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo get -f - --ignore-not-found -ojson]
Command output: []
2manifests to deploy.2are updated or new
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo apply -f -]
 - service/java-hello-world-external created
 - deployment.apps/java-hello-world created
Deploy completed in 732.892895ms
Waiting for deployments to stabilize...
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
checking status deployment/java-hello-world
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo rollout status deployment java-hello-world --namespace default --watch=false]
Command output: [Waiting for deployment "java-hello-world" rollout to finish: 0 of 1 updated replicas are available...
]
Pod "java-hello-world-8686b58cdc-gnwmk" scheduled but not ready: checking container statuses
 - pod/java-hello-world-8686b58cdc-gnwmk: creating container server
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo rollout status deployment java-hello-world --namespace default --watch=false]
Command output: [Waiting for deployment "java-hello-world" rollout to finish: 0 of 1 updated replicas are available...
]
Pod "java-hello-world-8686b58cdc-gnwmk" scheduled but not ready: checking container statuses
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo rollout status deployment java-hello-world --namespace default --watch=false]
Command output: [Waiting for deployment "java-hello-world" rollout to finish: 0 of 1 updated replicas are available...
]
Pod "java-hello-world-8686b58cdc-gnwmk" scheduled but not ready: checking container statuses
Fetching events for pod "java-hello-world-8686b58cdc-gnwmk"
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo rollout status deployment java-hello-world --namespace default --watch=false]
Command output: [deployment "java-hello-world" successfully rolled out
]
 - pod/java-hello-world-8686b58cdc-gnwmk: running.
 - deployment/java-hello-world is ready.
Deployments stabilized in 13.213 seconds
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
looking for port: 127.0.0.1:0
was able to obtain INADDR_ANY:4503
was able to obtain 127.0.0.1:4503
found open port: 4503
KubectlForwarder.Forward(java-hello-world-external): waiting on errChan
was able to obtain INADDR_ANY:4503
was able to obtain 127.0.0.1:4503
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
service java-hello-world-external/80 maps to 1 pods: [(pod:"java-hello-world-8686b58cdc-gnwmk" phase:Running created:2021-10-20 21:35:04 +0000 UTC)]
Forwarding service java-hello-world-external/80 to pod java-hello-world-8686b58cdc-gnwmk/8080
Running command: [kubectl --context gke_origin-demo_europe-west1_origin-demo port-forward --pod-running-timeout 1s --namespace default pod/java-hello-world-8686b58cdc-gnwmk 4503:8080]
[port-forward] Forwarding from 127.0.0.1:4503 -> 8080

KubectlForwarder.Forward(java-hello-world-external): got error on errChan, returning: <nil>
Port forwarding service/java-hello-world-external in namespace default, remote port 80 -> http://127.0.0.1:4503
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
podWatcher: waiting
podForwarder: waiting for pod events
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
getting client config for kubeContext: `gke_origin-demo_europe-west1_origin-demo`
podWatcher: waiting
containerManager: waiting for pod events
Press Ctrl+C to exit
podWatcher: waiting
logAggregator: waiting for pod events
Change detected<nil>
Not watching for changes...
[port-forward] Forwarding from [::1]:4503 -> 8080

Checking base image maven:3-jdk-11-slim for ONBUILD triggers.
Checking base image openjdk:11-jre-slim for ONBUILD triggers.
Found dependencies for dockerfile: [{pom.xml /app true} {. /app true}]
Skipping excluded path: .idea
Skipping excluded path: .readmes
Skipping excluded path: .vscode
Skipping excluded path: .dockerignore
dev intents: build false, sync false, deploy false
nicopoirier commented 3 years ago

Sorry error with the image name.

You can close the issue, it works :)

Sorry