Skip to content

Commit 1fa7e25

Browse files
committed
Proofread the tutorial
I went through all the content and made the following changes: - fixed typos - reported some issues that were not that easy to fix (for instance the use of dead punkapi.com in some sections) - adjusted the first tutorials to use Jackson instead of JSON-B: we recommend using Jackson. Also it avoids having to go back to switch from JSON-B to Jackson when dealing with Spring - the reactive sections are still using JSON-B for two reasons: they are using some JSON-P features and I couldn't test things given the API is not available. When reworking them, we should switch them to Jackson too. This is a bit massive, I will go through the changes and add comments when they are needed.
1 parent 4fa54b6 commit 1fa7e25

18 files changed

Lines changed: 241 additions & 261 deletions

documentation/modules/ROOT/pages/04_panache.adoc

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:project-name: tutorial-app
44

55
[#quarkusp-demo-overview]
6-
== Demo Overview
6+
== Demo Overview
77

88
You'll learn how easy and productive Quarkus is with Hibernate with Panache. For this, we'll develop a simple CRUD REST API that handles information about fruits.
99

@@ -21,12 +21,12 @@ Just open a new terminal window, and make sure you're at the root of your `{proj
2121
[tabs]
2222
====
2323
Maven::
24-
+
24+
+
2525
--
2626
[.console-input]
2727
[source,bash,subs="+macros,+attributes"]
2828
----
29-
./mvnw quarkus:add-extension -Dextension="rest-jsonb, jdbc-h2, hibernate-orm-panache, smallrye-openapi"
29+
./mvnw quarkus:add-extension -Dextension="rest-jackson, jdbc-h2, hibernate-orm-panache, smallrye-openapi"
3030
----
3131
3232
--
@@ -36,7 +36,7 @@ Quarkus CLI::
3636
[.console-input]
3737
[source,bash,subs="+macros,+attributes"]
3838
----
39-
quarkus extension add rest-jsonb jdbc-h2 hibernate-orm-panache smallrye-openapi
39+
quarkus extension add rest-jackson jdbc-h2 hibernate-orm-panache smallrye-openapi
4040
----
4141
--
4242
====
@@ -45,7 +45,7 @@ quarkus extension add rest-jsonb jdbc-h2 hibernate-orm-panache smallrye-openapi
4545
[.console-output]
4646
[source,text]
4747
----
48-
✅ Adding extension io.quarkus:quarkus-rest-jsonb
48+
✅ Adding extension io.quarkus:quarkus-rest-jackson
4949
✅ Adding extension io.quarkus:quarkus-smallrye-openapi
5050
✅ Adding extension io.quarkus:quarkus-hibernate-orm-panache
5151
✅ Adding extension io.quarkus:quarkus-jdbc-h2
@@ -144,7 +144,7 @@ Now we should have everything in place to query our *GET* REST endpoint:
144144
[.console-input]
145145
[source,bash]
146146
----
147-
curl localhost:8080/fruit
147+
curl -w '\n' localhost:8080/fruit
148148
----
149149

150150
[.console-output]
@@ -190,20 +190,19 @@ public class FruitResource {
190190
@Consumes(MediaType.APPLICATION_JSON)
191191
@Produces(MediaType.APPLICATION_JSON)
192192
public Response newFruit(Fruit fruit) {
193-
fruit.id = null;
194193
fruit.persist();
195194
return Response.status(Status.CREATED).entity(fruit).build();
196195
}
197196
198197
}
199198
----
200199

201-
Now you can insert a new fruit by using `curl`:
200+
Now you can insert a new fruit by using `curl`:
202201

203202
[.console-input]
204203
[source,bash]
205204
----
206-
curl -d "{\"name\": \"Banana\", \"season\": \"Summer\"}" -H "Content-Type: application/json" http://localhost:8080/fruit
205+
curl -w '\n' -d "{\"name\": \"Banana\", \"season\": \"Summer\"}" -H "Content-Type: application/json" http://localhost:8080/fruit
207206
----
208207

209208
[.console-output]
@@ -237,16 +236,16 @@ Create the file `import.sql` in the folder `src/main/resources` with the followi
237236
[.console-input]
238237
[source,sql]
239238
----
240-
create sequence fruit_sequence start with 1 increment by 1;
241-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Mango','Spring');
242-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Strawberry','Spring');
243-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Orange','Winter');
244-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Lemon','Winter');
245-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Blueberry','Summer');
246-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Banana','Summer');
247-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Watermelon','Summer');
248-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Apple','Fall');
249-
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Pear','Fall');
239+
INSERT INTO Fruit(id,name,season) VALUES (1,'Mango','Spring');
240+
INSERT INTO Fruit(id,name,season) VALUES (2,'Strawberry','Spring');
241+
INSERT INTO Fruit(id,name,season) VALUES (3,'Orange','Winter');
242+
INSERT INTO Fruit(id,name,season) VALUES (4,'Lemon','Winter');
243+
INSERT INTO Fruit(id,name,season) VALUES (5,'Blueberry','Summer');
244+
INSERT INTO Fruit(id,name,season) VALUES (6,'Banana','Summer');
245+
INSERT INTO Fruit(id,name,season) VALUES (7,'Watermelon','Summer');
246+
INSERT INTO Fruit(id,name,season) VALUES (8,'Apple','Fall');
247+
INSERT INTO Fruit(id,name,season) VALUES (9,'Pear','Fall');
248+
ALTER SEQUENCE fruit_seq RESTART WITH 10;
250249
----
251250

252251
And append the following configuration in `application.properties`:
@@ -315,16 +314,16 @@ Now if you refresh your browser pointing to http://localhost:8080/fruit[window=_
315314

316315
[TIP]
317316
====
318-
You can add different `import.sql` files based on the application profile.
317+
You can add different `import.sql` files based on the application profile.
319318
320-
For example: in dev mode, you
321-
can use the configuration `quarkus.hibernate-orm.sql-load-script=import-dev.sql`,
319+
For example: in dev mode, you
320+
can use the configuration `quarkus.hibernate-orm.sql-load-script=import-dev.sql`,
322321
while in production mode you can use `quarkus.hibernate-orm.sql-load-script=import-prod.sql`.
323322
====
324323

325324
== Adding a custom finder to the `Fruit` Entity
326325

327-
Update the `Fruit` class to contain a finder method `findBySeason` like:
326+
Update the `Fruit` class to contain a finder method `findBySeason` like:
328327

329328
[#quarkusp-find-fruits]
330329
[.console-input]
@@ -403,7 +402,7 @@ Let's try to filter only the fruits with the *Summer* season:
403402
[.console-input]
404403
[source,bash]
405404
----
406-
curl localhost:8080/fruit?season=Summer
405+
curl -w '\n' localhost:8080/fruit?season=Summer
407406
----
408407

409408
[.console-output]
@@ -518,7 +517,7 @@ Let's try again to filter only the fruits with the *Spring* season:
518517
[.console-input]
519518
[source,bash]
520519
----
521-
curl localhost:8080/fruit?season=Spring
520+
curl -w '\n' localhost:8080/fruit?season=Spring
522521
----
523522

524523
[.console-output]

documentation/modules/ROOT/pages/05_kubernetes.adoc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
= Deploying to Kubernetes
22

33
[.mt-4.right]
4-
image::openshift_sandbox.png[Openshift Sandbox,250,250,align="right",link="https://developers.redhat.com/developer-sandbox"]
4+
image::openshift_sandbox.png[OpenShift Sandbox,250,250,align="right",link="https://developers.redhat.com/developer-sandbox"]
55

6-
In this chapter we will push our newly built application to Kubernetes. If you don't have a Kubernetes instance at your disposal, you can create a free Openshift Sandbox instance on https://developers.redhat.com/developer-sandbox[developers.redhat.com/sandbox].
6+
In this chapter we will push our newly built application to Kubernetes. If you don't have a Kubernetes instance at your disposal, you can create a free OpenShift Sandbox instance on https://developers.redhat.com/developer-sandbox[developers.redhat.com/sandbox].
77

88

9-
10-
IMPORTANT: You will need a public container registry to store your image. If you don't have an account, we recommend to create a free account at http://quay.io[window=_blank].
9+
10+
IMPORTANT: You will need a public container registry to store your image. If you don't have an account, we recommend to create a free account at http://quay.io[window=_blank].
1111

1212
Our examples will be using the `quay.io` container registry and the `myrepo` organization, but you should change it to match your configuration.
1313

1414
== Adding the Kubernetes and Jib extensions
1515

16-
In this chapter we'll be using the Quarkus Kubernetes Extension to create the Kubernetes deployment file, and the Quarkus Jib Extension to create and push the container image to your container registry without the need of a local podman/docker instance.
16+
In this chapter we'll be using the Quarkus Kubernetes extension to create the Kubernetes deployment file, and the Quarkus Jib Extension to create and push the container image to your container registry without the need of a local Podman/Docker instance.
1717

1818
Let's add the required extensions:
1919

2020
[tabs]
2121
====
2222
Maven::
23-
+
23+
+
2424
--
2525
[.console-input]
2626
[source,bash,subs="+macros,+attributes"]
@@ -67,7 +67,7 @@ quarkus.kubernetes.service-type=load-balancer<5>
6767
<4> Tag of the container image. By default is the `version` element of `pom.xml`.
6868
<5> Create an external ip for the service.
6969

70-
IMPORTANT: Change `quay.io` to your container registry and `myrepo` to your organization.
70+
IMPORTANT: Change `quay.io` to your container registry and `myrepo` to your organization.
7171
If you don't, your push *will* fail.
7272

7373
== Authenticating and pushing the image to your container registry
@@ -80,12 +80,12 @@ In order to push the container image, you need to authenticate to your container
8080
docker login quay.io
8181
----
8282

83-
Now we're going to create the artifact, build a container and push it to our registry in one go using jib.
83+
Now we're going to create the artifact, build a container and push it to our registry in one go using Jib.
8484

8585
[tabs]
8686
====
8787
Maven::
88-
+
88+
+
8989
--
9090
[.console-input]
9191
[source,bash,subs="+macros,+attributes"]
@@ -105,7 +105,7 @@ quarkus image build jib --no-tests -D"quarkus.container-image.push=true"
105105
--
106106
====
107107

108-
NOTE: If you're having trouble with jib, you can also just use Docker/Podman to build & push. To do so, omit 'jib' from the command.
108+
NOTE: If you're having trouble with Jib, you can also just use Docker/Podman to build and push. To do so, omit 'jib' from the command.
109109

110110
[.console-output]
111111
[source,text]
@@ -127,9 +127,9 @@ NOTE: If you're having trouble with jib, you can also just use Docker/Podman to
127127

128128
== Deploy the application to your Kubernetes cluster
129129

130-
When a Kubernetes extension is present in the classpath, Quarkus will scaffold a Kubernetes deployment file in your target folder during the package phase. We can apply it to deploy the application to our Kubernetes cluster:
130+
When a Kubernetes extension is present in the classpath, Quarkus will scaffold a Kubernetes deployment file in your `target/` folder during the package phase. We can apply it to deploy the application to our Kubernetes cluster:
131131

132-
NOTE: You will need the https://kubernetes.io/docs/tasks/tools/[kubectl] or oc cli tool installed locally for the apply command below. https://developers.redhat.com/blog/2021/04/21/access-your-developer-sandbox-for-red-hat-openshift-from-the-command-line#[Here are instructions] to install the oc tool and log in to your Openshift Sandbox. Hint: your favorite package manager (dnf/brew/choco) can likely be used for the installation. Eg. `dnf install kubectl` or `choco install kubernetes-client` or `choco install openshift-client`
132+
NOTE: You will need the https://kubernetes.io/docs/tasks/tools/[kubectl] or `oc` cli tool installed locally for the apply command below. https://developers.redhat.com/blog/2021/04/21/access-your-developer-sandbox-for-red-hat-openshift-from-the-command-line#[Here are instructions] to install the `oc` tool and log in to your OpenShift Sandbox. Hint: your favorite package manager (dnf/brew/choco) can likely be used for the installation. Eg. `dnf install kubectl` or `choco install kubernetes-client` or `choco install openshift-client`
133133

134134
[tabs]
135135
====
@@ -161,7 +161,7 @@ deployment.apps/tutorial-app created
161161
----
162162

163163

164-
With the Quarkus CLI tool deploying is even easier. Instead of the above `kubectl apply` command, you can simply run `quarkus deploy` to deploy the application to your cluster. If you don't have the kubectl or oc cli installed or are not sure how to log in to your cluster, just add `-Dquarkus.kubernetes-client.api-server-url={yourServerUrl} -Dquarkus.kubernetes-client.token={myToken}` to the below command.
164+
With the Quarkus CLI tool, deploying is even easier. Instead of the above `kubectl apply` command, you can simply run `quarkus deploy` to deploy the application to your cluster. If you don't have the `kubectl` or `oc` CLI installed or are not sure how to log in to your cluster, just add `-Dquarkus.kubernetes-client.api-server-url={yourServerUrl} -Dquarkus.kubernetes-client.token={myToken}` to the below command.
165165
[.console-input]
166166
[source,bash,subs="+macros,+attributes"]
167167
----
@@ -174,10 +174,10 @@ After the command has finished, you might need to wait a few more seconds until
174174

175175
[tabs]
176176
====
177-
Openshift Sandbox / Kubernetes on AWS::
177+
OpenShift Sandbox / Kubernetes on AWS::
178178
+
179179
--
180-
If using a hosted Kubernetes cluster like OpenShift (Sandbox) on AWS then use curl and the EXTERNAL-IP address with port `8080` or get it using `kubectl`:
180+
If using a hosted Kubernetes cluster like OpenShift (Sandbox) on AWS then use `curl` and the `EXTERNAL-IP` address with port `8080` or get it using `kubectl`:
181181
182182
:tmp-service-exposed: tutorial-app
183183
@@ -207,7 +207,7 @@ echo $IP:$PORT
207207
Hosted::
208208
+
209209
--
210-
If using a hosted Kubernetes cluster like OpenShift then use curl and the EXTERNAL-IP address with port `8080` or get it using `kubectl`:
210+
If using a hosted Kubernetes cluster like OpenShift then use `curl` and the `EXTERNAL-IP` address with port `8080` or get it using `kubectl`:
211211
212212
:tmp-service-exposed: tutorial-app
213213
@@ -237,18 +237,18 @@ curl $IP:$PORT/hello
237237
Hello y'all!
238238
----
239239

240-
If you're using the Openshift Sandbox UI, you can also find the application running in the "Topology" view as seen in the screenshot below:
240+
If you're using the OpenShift Sandbox UI, you can also find the application running in the "Topology" view as seen in the screenshot below:
241241

242242
[.mt-4.center]
243243
image::Openshift.png[Openshift,400,400,align="center"]
244244

245245
[sidebar]
246246
--
247-
TIP: If you're using Openshift (Sandbox) and would like to create a url you can share to the outside world, you can create it like so:
247+
TIP: If you're using OpenShift (Sandbox) and would like to create a url you can share to the outside world, you can create it like so:
248248
[.console-input]
249249
[source,bash,subs="+macros,+attributes"]
250250
----
251-
oc create route edge --service=tutorial-app
251+
oc create route edge --service=tutorial-app
252252
url=$(oc get route tutorial-app -o jsonpath='{.spec.host}')
253253
curl https://$url/hello
254254
----

0 commit comments

Comments
 (0)