Skip to content

Commit 750db1f

Browse files
committed
update images and .md / formating
1 parent cb664fd commit 750db1f

File tree

134 files changed

+218
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+218
-135
lines changed
Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1-
# Backend
1+
# Deploy the Backend Docker Image to Kubernetes
22

33
## Introduction
44

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.
66

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+
![bcknd apis](images/Backend-APIs.png)
832

933
### Objectives
1034

@@ -16,36 +40,17 @@ Estimated time: ~25-minutes.
1640

1741
### Prerequisites
1842

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-
![](images/Backend-APIs.png " ")
43+
* This lab requires the completion of the **Setup Dev Environment** tutorial and the provisioning of the Orace Cloud Infrastructure (OCI) components.
3944

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
4146

4247
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.
4348

4449
1. Edit ./backend/src/main/java/com/oracle/todoapp/Main.java
4550

4651
- Locate the following code fragment
4752

48-
![](images/CORS-Main.png " ")
53+
![](images/cors-main.png " ")
4954
- Replace `eu-frankfurt-1` in `"https://objectstorage.eu-frankfurt-1.oraclecloud.com"` with your region
5055

5156
- Save the file
@@ -55,7 +60,9 @@ This will allow the appropriate object storage bucket to access your application
5560
2. Run `build.sh` script to build and push the helidon-se image into the repository
5661

5762
```
63+
<copy>
5864
cd $MTDRWORKSHOP_LOCATION/backend
65+
</copy>
5966
./build.sh
6067
```
6168
In a couple of minutes, you should have successfully built and pushed the images into the OCI repository.
@@ -64,81 +71,92 @@ This will allow the appropriate object storage bucket to access your application
6471
- Go to the Console, click the hamburger menu in the top-left corner and open
6572
**Developer Services > Container Registry**.
6673
67-
![](psong_images/container_registry.png)
74+
![](images/container-registry.png)
6875
69-
## **Task 2**: Deploy on Kubernetes and Check the Status
76+
## Task 2: Deploy on Kubernetes and Check the Status
7077
7178
1. Run the `deploy.sh` script
7279
7380
```
81+
<copy>
7482
cd $MTDRWORKSHOP_LOCATION/backend
7583
./deploy.sh
84+
</copy>
7685
```
7786
7887
If everything runs correctly the script will output something like this.
7988
80-
![](psong_images/deploy_output.png)
89+
![](images/deploy-output.png)
8190
8291
8392
2. Check the status using the following commands
8493
8594
The following command returns the Kubernetes service of MyToDo application with a load balancer exposed through an external API
8695
```
96+
<copy>
8797
services
98+
</copy>
8899
```
89100
This will run `kubectl get services` in the background, but the setup script creates aliases for ease of use
90101
91-
![](psong_images/get_services.png)
102+
![](images/get-services.png)
92103
93104
3. The following command returns all the pods running in your kubernetes cluster:
94105
```
106+
<copy>
95107
pods
108+
</copy>
96109
```
97110
This will run `kubectl get pods` in the background, but the setup script creates aliases for ease of use
98111
99-
![](psong_images/get_pods.png)
112+
![](images/get-pods.png)
100113
101114
5. You can tail the log of one of the pods by running:
102115
103116
```
117+
<copy>
104118
kubectl -n mtdrworkshop logs -f <pod name>
119+
</copy>
105120
```
106121
107122
$ kubectl logs -f <pod name>
108123
Example: `kubectl -n mtdrworkshop logs -f todolistapp-helidon-se-deployment-7fd6dcb778-c9dbv`
109124
110-
![](psong_images/pod_logs.png)
125+
![](images/pod-logs.png)
111126
112127
If the logs return `webserver is up!` then you have done everything correctly.
113-
## **Task 3**: UnDeploy (optional)
128+
## Task 3: UnDeploy (optional)
114129
115130
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.
116131
117132
1. Run the `undeploy.sh` script
118133
```
119-
cd $MTDRWORKSHOP_LOCATION/backend; ./undeploy.sh
134+
<copy>
135+
cd $MTDRWORKSHOP_LOCATION/backend
136+
./undeploy.sh
137+
</copy>
120138
```
121139
2. Rebuild the image + Deploy + (Re)Configure the API Gateway
122140
123-
## **Task 4**: Configure the API Gateway
141+
## Task 4: Configure the API Gateway
124142
125143
The API Gateway protects any RESTful service running on Container Engine for Kubernetes, Compute, or other endpoints through policy enforcement, metrics and logging.
126144
Rather than exposing the Helidon service directly, we will use the API Gateway to define cross-origin resource sharing (CORS).
127145
128146
The setup script already creates an API gateway, but you still need to create the deployments in the API gateway.
129147
130148
1. From the hamburger menu navigate **Developer Services** > **API Management > Gateways**
131-
![](psong_images/api_gateway_navigate.png)
149+
![](images/api-gateway-navigate.png)
132150
133151
2. Click on the todolist gateway that has been created for you
134-
![](psong_images/select_gateway.png)
152+
![](images/select-gateway.png)
135153
136154
3. Create a todolist deployment by clicking create deployment
137-
![](psong_images/create_deployment.png)
155+
![](images/create-deployment.png)
138156
139157
4. Fill out the basic information like so:
140158
141-
![](psong_images/basic_information_deployment.png)
159+
![](images/basic-information-deployment.png)
142160
5. Configure Cross-origin resource sharing (CORS) policies.
143161
- CORS is a security mechanism that will prevent loading resources from unspecified origins (domain, scheme, or port).
144162
- 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
148166
149167
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.
150168
151-
![](psong_images/cors_information.png)
169+
![](images/cors-information.png)
152170
153171
6. Configure the Headers
154172
155-
![](images/Headers.png)
173+
![](images/headers.png)
156174
157175
7. Configure the routes: we will define two routes:
158176
- /todolist for the first two APIs: GET, POST and OPTIONS
159177
160-
![](psong_images/route_1.png)
178+
![](images/route-1.png)
161179
162180
- /todolist/{id} for the remaining three APIs: (GET, PUT and DELETE)
163181
164-
![](psong_images/route_2.png)
182+
![](images/route-2.png)
165183
166184
167-
## **Task 5**: Testing the backend application through the API Gateway
185+
## Task 5: Testing the Backend Application Through the API Gateway
168186
169187
1. Navigate to the newly create Gateway Deployment Detail an copy the endpoint
170-
![](psong_images/copy_endpoint.png " ")
188+
![](images/copy-endpoint.png " ")
171189
172190
2. Testing through the API Gateway endpoint
173191
postfix the gateway endpoint with "/todolist" as shown in the image below
174192
175-
![](psong_images/endpoint_successful.png " ")
193+
![](images/endpoint-successful.png " ")
176194
177195
It should display the Todo Item(s) in the TodoItem table that was created during the setup.
178196
179-
Congratulations, you have completed lab 2; you may now [proceed to the next lab](#next).
197+
You may now **proceed to the next lab**.
180198
181199
## Acknowledgements
182200
-26.2 KB
Binary file not shown.
-42.1 KB
Binary file not shown.
-57.2 KB
Binary file not shown.
-68.2 KB
Binary file not shown.
-13.2 KB
Binary file not shown.
-12.6 KB
Binary file not shown.
-18.1 KB
Binary file not shown.
-53.4 KB
Binary file not shown.
-18.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)