You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mtdrworkshop/backend/backend.md
+64-46Lines changed: 64 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,34 @@
1
-
# Backend
1
+
# Deploy the Backend Docker Image to Kubernetes
2
2
3
3
## Introduction
4
4
5
-
In this lab, you will build and deploy the pre-built Helidon Java Docker image to OKE, then configure the API Gateway to work with your application.
5
+
In this lab, you will build and deploy the pre-built Helidon Java backend Docker image to OKE, then configure the API Gateway.
6
6
7
-
Estimated time: ~25-minutes.
7
+
Estimated time: 25 minutes
8
+
9
+
Watch the video below for a quick walk through of the lab.
10
+
11
+
[](youtube:Th7YCV6e8CE)
12
+
13
+
### Understand the Java backend application
14
+
15
+
As with most React applications (https://reactjs.org/), this application uses remote APIs to handle data persistence. The backend implements five REST APIs including:
16
+
17
+
* Retrieving the current list of todo items
18
+
* Adding a new todo item
19
+
* Finding a todo item by its ID
20
+
* Updating an existing todo item
21
+
* Deleting a todo item
22
+
23
+
The APIs are documented using Swagger at http://130.61.67.158:8780/swagger-ui/#/.
24
+
25
+
The backend is implemented using the following Java classes (under ./backend/src/...):
26
+
27
+
* Main.java: starts and configures the main entry points
28
+
* ToDoItem.java: maps a Todo Item instance to and from the JSON document
29
+
* ToDoItemStorage.java: stores the Todo item in a persistent store that is the Oracle Autonomous database
30
+
* ToDoListAppService.java: implements the Helidon service and exposes the REST APIs
31
+

8
32
9
33
### Objectives
10
34
@@ -16,36 +40,17 @@ Estimated time: ~25-minutes.
16
40
17
41
### Prerequisites
18
42
19
-
This lab requires the completion of lab 1 and the provision of the OCI components.
20
-
21
-
### Understanding the Java/backend application
22
-
23
-
As with most React applications (https://reactjs.org/), this application uses remote APIs to handle data persistence. The backend implements 5 REST APIs including:
24
-
- Retrieving the current list of todo items
25
-
- Adding a new todo item
26
-
- Finding a todo item by its id
27
-
- Updating an existing todo item
28
-
- Deleting a todo item.
29
-
30
-
The APIs are documented using Swagger @ http://130.61.67.158:8780/swagger-ui/#/
31
-
32
-
The backend is implemented using the following Java classes (under ./backend/src/...):
33
-
- Main.java: starts and configure the main entry points.
34
-
- ToDoItem.java: maps a Todo Item instance to/from JSON document
35
-
- ToDoItemStorage.java: stores the Todo item in a persistent store i.e., the Oracle Autonomous database
36
-
- ToDoListAppService.java: implements the Helidon service and exposes the REST APIs
37
-
38
-

43
+
* This lab requires the completion of the **Setup Dev Environment** tutorial and the provisioning of the Orace Cloud Infrastructure (OCI) components.
39
44
40
-
## **Task 1**: Build and push the Docker images to the OCI Registry
45
+
## Task 1: Build and Push the Docker Images to the OCI Registry
41
46
42
47
The OCI Container Regisry is where your Docker images are managed. A container registry should have been created for you in Lab 1 in your compartment.
If the logs return `webserver is up!` then you have done everything correctly.
113
-
## **Task 3**: UnDeploy (optional)
128
+
## Task 3: UnDeploy (optional)
114
129
115
130
If you make changes to the image, you need to delete the service and the pods by running undeploy.sh then redo Steps 2 & 3.
116
131
117
132
1. Run the `undeploy.sh` script
118
133
```
119
-
cd $MTDRWORKSHOP_LOCATION/backend; ./undeploy.sh
134
+
<copy>
135
+
cd $MTDRWORKSHOP_LOCATION/backend
136
+
./undeploy.sh
137
+
</copy>
120
138
```
121
139
2. Rebuild the image + Deploy + (Re)Configure the API Gateway
122
140
123
-
## **Task 4**: Configure the API Gateway
141
+
## Task 4: Configure the API Gateway
124
142
125
143
The API Gateway protects any RESTful service running on Container Engine for Kubernetes, Compute, or other endpoints through policy enforcement, metrics and logging.
126
144
Rather than exposing the Helidon service directly, we will use the API Gateway to define cross-origin resource sharing (CORS).
127
145
128
146
The setup script already creates an API gateway, but you still need to create the deployments in the API gateway.
129
147
130
148
1. From the hamburger menu navigate **Developer Services** > **API Management > Gateways**
131
-

149
+

132
150
133
151
2. Click on the todolist gateway that has been created for you
134
-

152
+

135
153
136
154
3. Create a todolist deployment by clicking create deployment
- CORS is a security mechanism that will prevent loading resources from unspecified origins (domain, scheme, or port).
144
162
- Allowed Origins: is the list of all servers (origins) that are allowed to access the API deployment typically your Kubernetes cluster IP.
@@ -148,35 +166,35 @@ The setup script already creates an API gateway, but you still need to create th
148
166
149
167
To configure CORS, scroll down and click add next to CORS and fill in this information under allowed origins. These are the origins that can load resources to your application.
150
168
151
-

169
+

152
170
153
171
6. Configure the Headers
154
172
155
-

173
+

156
174
157
175
7. Configure the routes: we will define two routes:
158
176
- /todolist for the first two APIs: GET, POST and OPTIONS
159
177
160
-

178
+

161
179
162
180
- /todolist/{id} for the remaining three APIs: (GET, PUT and DELETE)
163
181
164
-

182
+

165
183
166
184
167
-
## **Task 5**: Testing the backend application through the API Gateway
185
+
## Task 5: Testing the Backend Application Through the API Gateway
168
186
169
187
1. Navigate to the newly create Gateway Deployment Detail an copy the endpoint
170
-

188
+

171
189
172
190
2. Testing through the API Gateway endpoint
173
191
postfix the gateway endpoint with "/todolist" as shown in the image below
174
192
175
-

193
+

176
194
177
195
It should display the Todo Item(s) in the TodoItem table that was created during the setup.
178
196
179
-
Congratulations, you have completed lab 2; you may now [proceed to the next lab](#next).
0 commit comments