Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WildFly mini series: REST Client #671

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tommaso-borgato
Copy link
Contributor

@tommaso-borgato tommaso-borgato commented Oct 17, 2024

This PR contains 3 more guides to be added to the Java Microservices on Kubernetes with WildFly:

  1. HOW-TO invoke one microservice from another microservice
  2. HOW-TO to do it on Kubernetes
  3. HOW-TO to propagate security data

wildfly-extras/guides#4 contains the source code for all the 3 new guides

#676 contains a proposal on HOW-TO re-organize the whole "WildFly mini series" contents

Fixes #687

@tommaso-borgato
Copy link
Contributor Author

tommaso-borgato commented Nov 7, 2024

@bstansberry can you assign a reviewer for this one?

Also wildfly-extras/guides#4 would need a reviewer ...

@asoldano asoldano requested a review from jamezp November 7, 2024 10:36
@asoldano
Copy link
Contributor

asoldano commented Nov 7, 2024

As this involves REST Client, I think @jamezp might want to review

@jamezp
Copy link
Member

jamezp commented Nov 7, 2024

I'll try to have a look this week or early next week. I've got to get a RESTEasy release out, so once that's done I should have some time.

Copy link
Member

@jamezp jamezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had to stop the process of checking this on the second part as it's not working for me.

@@ -3,13 +3,14 @@
:jaxrs-example-project-artifactId: jaxrs
:jaxrs-example-project-version: 11.0.0.Final-SNAPSHOT
:version-bootable-jar: 11.0.0.Beta1
:version-wildfly: 32.0.0.Final
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using WildFly 32? Shouldn't we use WildFly 34?


@RegisterRestClient(configKey="simple-microservice-server")
@Path("/hello")
public interface GettingStartedEndpointInterface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should name this something like GettingStartedClient or GettingStartedEndpointClient.

Comment on lines 49 to 52
* remove folder *src/test*
* remove all test scope dependencies

NOTE: we remove tests in preparation for the upcoming guides
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow this and it seems a bit odd to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamezp I changed the wording ... I was basically trying to say that the tests that were included with the archetype wouldn't be relevant anymore since we are using service to service invocation


==== pom.xml

Set `<artifactId>simple-microservice-server</artifactId>`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to be more descriptive here and state something like:

Update the artifactId to <artifactid>simple-microservice-server</artifactId>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamezp tnks, changed

Comment on lines 71 to 78
Since you copied {source-code-git-repository}/simple-microservice[simple-microservice], the Dockerfile from link:https://github.com/wildfly/wildfly-s2i/blob/main/examples/docker-build/Dockerfile[examples/docker-build/Dockerfile, window="_blank"] should already be at the root of your project;

==== Build the Docker Image

[source,bash,subs="normal"]
----
podman build -t {my-jaxrs-app-docker-image-name-server}:latest .
----
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't use the wildfly-maven-plugin to generate the Dockerfile/image?

Copy link
Contributor Author

@tommaso-borgato tommaso-borgato Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamezp thank you for the suggestion ... if you agree I'll add a note that tells about this option (https://docs.wildfly.org/wildfly-maven-plugin/releases/5.1/image-mojo.html) ... throughout the guides I tried to keep it stupid simple and just use the minimal set of tools/configurations the user might be already familiar with ... for example I didn't use glow ... my fear is that the reader might abandon the reading if feeling overwhelmed with too many tools/configurations ... I also wanted to show what's going on under the hood to show it's actually simple stuff

----
podman run --rm -p 8080:8080 -p 9990:9990 \
--network={podman-network-name} \
--env "SIMPLE_MICROSERVICE_SERVER_URI=http://{my-jaxrs-app-docker-image-name-server}:8080/hello" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hello needs to be removed at the end since the GettingStartedEndpointInterface includes @Path("/hello").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamezp great catch! Thank you


=== Deploy on Kubernetes

Create a file named `{my-jaxrs-app-docker-image-name-server}-deployment.yaml`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do I create this file? I assume in simple-microservice-server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added instructions on where to create kubernetes files


[source,bash,subs="normal"]
----
kubectl apply -f {my-jaxrs-app-docker-image-name-server}-deployment.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails if Kubernetes is not running. We should add a step for minikube start.


=== Create Kubernetes ClusterIP Service

We create a service to consume the services exposed by **{my-jaxrs-app-docker-image-name-server}** from inside Kubernetes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I assume this needs to happen in the client, but it's not really described. Or I guess in any directory, but seems it should specify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a link to https://kubernetes.io/docs/concepts/services-networking/service/ which should clarify this statement


[source,bash,subs="normal"]
----
kubectl run --rm -it --tty curl-{my-jaxrs-app-docker-image-name-server} --image=curlimages/curl --restart=Never &dash;&dash; {my-jaxrs-app-docker-image-name-server}-service:8080/hello/pippo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for me. It's possible I don't have minikube started correctly. I just did minikube start.

If you don't see a command prompt, try pressing enter.
curl: (6) Could not resolve host: xxx
Hello 'pippo'.pod "curl-my-jaxrs-app-server" deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just deleted and re-installed a fresh minikube .... perhaps the two dashed get copied to some other character ...

try:

kubectl run --rm -it --tty curl-simple-microservice-server --image=curlimages/curl --restart=Never -- http://simple-microservice-server-service:8080/hello/pippo

it worked for me ....

@tommaso-borgato tommaso-borgato force-pushed the wildfly-mini-serie-client-service branch 4 times, most recently from b97e844 to ffb745e Compare November 28, 2024 09:37
@tommaso-borgato tommaso-borgato force-pushed the wildfly-mini-serie-client-service branch 5 times, most recently from 67aa8e7 to cf300a6 Compare November 29, 2024 14:27
@tommaso-borgato tommaso-borgato force-pushed the wildfly-mini-serie-client-service branch from cf300a6 to c14e95d Compare November 29, 2024 15:18
@tommaso-borgato
Copy link
Contributor Author

tommaso-borgato commented Nov 29, 2024

@jamezp Thank you for your review! I hope I have fixed everything you pointed out

@tommaso-borgato
Copy link
Contributor Author

@jamezp Thank you again fro your review, do you think this is ready to be merged now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Guide: WildFly mini series: REST Client
3 participants