eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
733 stars 481 forks source link

[Maven Quickstarts]: hello-world curl request fails #3327

Open lcardito opened 3 weeks ago

lcardito commented 3 weeks ago

Component

Kubernetes Maven Plugin

Task description

Description

Hey team, apologies if this is not the right type. This seems to be a docs issue potentially rather than anything else.

Running the helloworld quickstart curl test does not return any response.

I've ran all the steps in the README.md for the helloworld quick start. I can see the pod running no issues, however when running the curl test I get a "Couldn't connect to server" error.

❯ kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
helloworld   NodePort    10.106.132.58   <none>        8080:32374/TCP   57s
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP          27m
❯ curl $(minikube ip):$(kubectl get svc helloworld -n default -o jsonpath='{.spec.ports[].nodePort}')
curl: (28) Failed to connect to 192.168.58.2 port 32374 after 75002 ms: Couldn't connect to server

I found a related issue with Micronaut https://github.com/eclipse-jkube/jkube/issues/1429, in the helloworld example as well we might want to update the docs once I can get it running 😄

Expected Behavior

Running the helloworld quickstart curl Hello World

Acceptance Criteria

rohanKanojia commented 3 weeks ago

@lcardito : Hello, thanks a lot for trying out the project.

I tried reproducing the issue but I couldn't reproduce it. Could you please check if it works if you use minikube service command like this?

curl `minikube service helloworld --url`/hello

Maybe application isn't build correctly? Have you packaged your application using mvn package first? Do you see anything fishy when you do mvn k8s:log?

lcardito commented 3 weeks ago

Hey @rohanKanojia I am trying to get to the bottom of it. I think my docker setup on the M1 mac might have something todo with it.

From mvn k8s:log everything looks ok

❯ mvn k8s:log
[INFO] Scanning for projects...
[INFO]
[INFO] -----------< org.eclipse.jkube.quickstarts.maven:helloworld >-----------
[INFO] Building Eclipse JKube :: Quickstarts :: Maven :: Hello World 1.17.0
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- k8s:1.17.0:log (default-cli) @ helloworld ---
[INFO] k8s: Using Kubernetes at https://127.0.0.1:32769/ in namespace null with manifest /Users/card74944/projects/jkube/quickstarts/maven/hello-world/target/classes/META-INF/jkube/kubernetes.yml
[INFO] k8s: Watching pods with selector LabelSelector(matchExpressions=[], matchLabels={app=helloworld, provider=jkube, group=org.eclipse.jkube.quickstarts.maven, app.kubernetes.io/name=helloworld, app.kubernetes.io/part-of=org.eclipse.jkube.quickstarts.maven, app.kubernetes.io/managed-by=jkube}, additionalProperties={}) waiting for a running pod...
[INFO] k8s:  [NEW] helloworld-65876ffb54-v8xhr status: Running Ready
[INFO] k8s:  [NEW] Tailing log of pod: helloworld-65876ffb54-v8xhr container: hello-world
[INFO] k8s:  [NEW] Press Ctrl-C to stop tailing the log
[INFO] k8s:  [NEW]
[INFO] k8s: Aug 21, 2024 8:32:19 AM org.eclipse.jkube.sample.helloworld.App main
[INFO] k8s: INFO: Server started on port: 8080

The following command

❯ curl `minikube service helloworld --url`/hello
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

is pointing me at something similar to https://github.com/kubernetes/minikube/issues/13788#issuecomment-1068640594. Did not manage to make it work yet, I'll spend some more time troubleshooting later on today.

rohanKanojia commented 3 weeks ago

@lcardito : If this issue is blocking you maybe you can try some cloud Kubernetes provider. Red Hat provides a developer sandbox with which you can create a small OpenShift cluster . It's good enough for experimenting.

lcardito commented 3 weeks ago

@rohanKanojia - bingo. As mentioned in the linked issue on darwin looks like we need to access the service via an ssh tunnel. Doing

❯ minikube service helloworld --url
http://127.0.0.1:64657

and then hitting that url with

❯ curl http://127.0.0.1:64657/hello
Hello World%

works.

It is worth it for this project to also update the docs to run those quickstarts on MacOs? (unsure if it's only with M1 macs though..)

rohanKanojia commented 3 weeks ago

@lcardito : Feel free to update the docs to make it easier for newcomers to troubleshoot issues like these.

manusa commented 2 weeks ago

the doc for this quickstart is not consistent with the rest, we should use always minikube service to retrieve the valid URL.

lcardito commented 2 weeks ago

@manusa yeah - can you leave it with me? I can put together a PR to make it consistent and add a note for the new mac M1 onwards