|
19 | 19 |
|
20 | 20 | A devfile-based application stack for Open Liberty
|
21 | 21 |
|
22 |
| -## Contributing |
23 |
| - |
24 |
| -Our [CONTRIBUTING](https://github.com/OpenLiberty/application-stack/blob/master/CONTRIBUTING.md) document contains details for submitting pull requests. |
25 |
| - |
26 | 22 | # Open Liberty Application Stack
|
27 | 23 |
|
28 | 24 | The Open Liberty application stack provides a consistent way of developing microservices based upon the [Jakarta EE](https://jakarta.ee/) and [Eclipse MicroProfile](https://microprofile.io) specifications. This stack lets you use [Maven](https://maven.apache.org) to develop applications for [Open Liberty](https://openliberty.io) runtime, that is running on OpenJDK with container-optimizations in OpenJ9.
|
29 | 25 |
|
30 |
| -This stack is based on OpenJDK with container-optimizations in OpenJ9 and `Open Liberty v20.0.0.9`. It provides live reloading during development by utilizing the ["dev mode"](https://openliberty.io/blog/2019/10/22/liberty-dev-mode.html) capability in the liberty-maven-plugin. |
| 26 | +This stack is based on OpenJDK with container-optimizations in OpenJ9 and Open Liberty. It provides live reloading during development by utilizing the ["dev mode"](https://openliberty.io/blog/2019/10/22/liberty-dev-mode.html) capability in the liberty-maven-plugin. |
31 | 27 |
|
32 | 28 | **Note:** Maven is provided by the stack, allowing you to build, test, and debug your Java application without installing Maven locally.
|
33 | 29 |
|
34 |
| -## Default starter app |
35 |
| - |
36 |
| -The default starter provides a `pom.xml` file that enables Liberty features that support [Eclipse MicroProfile 3.3](https://openliberty.io/docs/ref/feature/#microProfile-3.3.html). Specifically, this template includes: |
37 |
| - |
38 |
| -#### Health |
39 |
| - |
40 |
| -The `mpHealth` feature allows services to report their readiness and liveness status - UP if it is ready or alive and DOWN if it is not ready/alive. It publishes two corresponding endpoints to communicate the status of liveness and readiness. A service orchestrator can then use the health statuses to make decisions. |
41 |
| - |
42 |
| -Liveness endpoint: http://localhost:9080/health/live |
43 |
| -Readiness endpoint: http://localhost:9080/health/ready |
44 |
| - |
45 |
| -#### Metrics |
46 |
| - |
47 |
| -The `mpMetrics` feature enables MicroProfile Metrics support in Open Liberty. Note that this feature requires SSL and the configuration has been provided for you. You can monitor metrics to determine the performance and health of a service. You can also use them to pinpoint issues, collect data for capacity planning, or to decide when to scale a service to run with more or fewer resources. |
48 |
| - |
49 |
| -Metrics endpoint: http://localhost:9080/metrics |
50 |
| - |
51 |
| -##### Metrics Password |
52 |
| - |
53 |
| -Security for the development image is enabled via Open Liberty's `<quickStartSecurity>` configuration. This mechanism provides a basic username/password to the server and is intended for development. It is intentionally removed when an official production image is built. |
54 |
| - |
55 |
| -Log in as the `admin` user to see both the system and application metrics in a text format. The password for this `admin` user will be generated by the container. |
56 |
| - |
57 |
| -To get the generated password for your project, you can exec in the container with these steps: |
58 |
| - |
59 |
| -1. List the name of the pod running in the current namespace: |
60 |
| - |
61 |
| - $ kubectl get pods |
62 |
| - |
63 |
| -1. Use the oc tool to open a remote session to your pod, and print the keystore_password created for the Open Liberty server: |
64 |
| - |
65 |
| - $ oc rsh <pod_name> |
66 |
| - $ grep keystore /projects/target/liberty/wlp/usr/servers/defaultServer/server.env |
67 |
| - |
68 |
| - keystore_password=2r1aquTO3VVUVON7kCDdzno |
69 |
| - |
70 |
| -So in this example the password value would be: `2r1aquTO3VVUVON7kCDdzno` |
71 |
| - |
72 |
| - |
73 |
| -#### Junit 5 |
74 |
| - |
75 |
| -The default template uses JUnit 5. You may be used to JUnit 4, but here are some great reasons to make the switch https://developer.ibm.com/dwblog/2017/top-five-reasons-to-use-junit-5-java/ |
76 |
| - |
77 |
| - |
78 | 30 | ## Getting Started
|
79 | 31 |
|
80 |
| -1. Perform an `oc login` to your Open Shift cluster for development purposes. |
| 32 | +> It's recommended to use the latest version of OpenShift Do (odo). You can install odo using [these instructions](https://odo.dev/docs/installing-odo/) |
| 33 | +
|
| 34 | +1. Perform an `oc login` to your cluster. |
81 | 35 |
|
82 |
| -1. Install the latest vesion of OpenShift Do (odo) using [these instructions](https://odo.dev/docs/installing-odo/) |
| 36 | +1. Create a new odo project |
83 | 37 |
|
84 |
| - <!-- Keep for now in case future changes require experimental mode |
85 |
| - 1. Odo must be run in experimental mode at the 1.x level in order to access the devfile support. Enable experimental mode using the odo CLI: |
86 | 38 | ```shell
|
87 |
| - odo preference set experimental true |
| 39 | + odo project create my-project |
88 | 40 | ```
|
89 |
| - ---> |
90 | 41 |
|
91 |
| -1. Create a new folder in your local directory and create an odo project using the odo CLI, e.g.: |
| 42 | + This will create a new namespace in your cluster called `my-project` |
| 43 | + |
| 44 | +1. Initialize the local folder with the Open Liberty stack |
| 45 | + |
92 | 46 | ```shell
|
93 | 47 | mkdir my-project
|
94 | 48 | cd my-project
|
95 |
| - odo project create <project namespace name> |
96 |
| - ``` |
97 |
| - The project namespace name will be used to create an OpenShift namespace that will house your application and related pods |
98 |
| - |
99 |
| -1. Initialize the local folder using the Open Liberty stack. |
100 |
| - ```shell |
101 | 49 | odo create java-openliberty --starter
|
102 | 50 | ```
|
103 | 51 |
|
104 |
| - This will initialize an Open Liberty project and download the default starter app artifacts. |
| 52 | + This will download the default starter app |
105 | 53 |
|
106 |
| -1. Once your project has been initialized, you can push your application to your OpenShift cluster for the first time using the following command: |
| 54 | +1. Push your app to your cluster |
107 | 55 |
|
108 | 56 | ```shell
|
109 | 57 | odo push
|
110 | 58 | ```
|
111 | 59 |
|
112 |
| - Upon a first time `odo push` invocation, the following occurs: |
113 |
| - - An Open Shift managed kubernetes pod is launched within the namespace created in step 3 above, |
114 |
| - - A container based on the image referenced in the devfile is started in that pod |
115 |
| - - odo syncs your local source code directory to that container. (under the `/projects` directory) |
116 |
| - - The app is compiled and built within the container and liberty dev mode is started to host the app once built. |
117 |
| - - A URL is activated and is usable to access the app |
118 |
| - |
119 |
| -1. Retrieve the URL for your app using the odo CLI: |
| 60 | +1. Retrieve the URL for your app |
120 | 61 |
|
121 | 62 | ```shell
|
122 | 63 | odo url list
|
123 | 64 | ```
|
124 | 65 |
|
125 |
| -1. You should be able to access the following endpoints, as they are exposed by your template application by default: |
126 |
| - |
127 |
| - - Readiness endpoint: http://`<odo url>`/health/ready |
128 |
| - - Liveness endpoint: http://`<odo url>>`/health/live |
129 |
| - - Metrics endpoint: http://`<odo url>`/metrics (login as `admin` user with password obtained as mentioned [here](#Metrics-Password). |
130 |
| - |
131 |
| -To see source code changes reflected in the running application you can re-issue the `odo push` command after any edit session is complete and saved. Source code changes will be reflected in the running container within a few seconds. Alternatively, you can issue `odo watch` once which will monitor for changes in your local project and automatically push changes to your remote cluster. |
132 |
| - |
133 |
| -## Creating a project from an existing application |
134 |
| - |
135 |
| -You can initialize an existing application as a stack project. The following steps show how to do this using the Open Liberty [application-stack-intro sample application](https://github.com/OpenLiberty/application-stack-intro). |
136 |
| - |
137 |
| -1. Clone the application-stack-intro repository |
138 |
| - |
139 |
| -```shell |
140 |
| -git clone [email protected]:OpenLiberty/application-stack-intro.git |
141 |
| -cd application-stack-intro |
142 |
| -``` |
143 |
| - |
144 |
| -2. Initialize the project with the java-openliberty stack |
145 |
| - |
146 |
| -```shell |
147 |
| -odo create java-openliberty my-component |
148 |
| -``` |
149 |
| - |
150 |
| -3. Push the sample application to OpenShift |
151 |
| - |
152 |
| -```shell |
153 |
| -odo push |
154 |
| -``` |
155 |
| - |
156 |
| -For more details on the application-stack-intro application, check out https://github.com/OpenLiberty/application-stack-intro |
157 |
| - |
158 |
| -## Odo development operations |
| 66 | + This URL will show the starter app's welcome page by default. |
159 | 67 |
|
160 |
| -### PUSH |
161 |
| -By default, `odo push`, in conjuction with the java-openliberty devfile, runs a liberty:dev mode in "hot test" mode, where unit tests and integration tests get automatically re-executed after each detected change. These test results are visible in the OpenShift container logs. To see the realtime contents of the container logs, use the odo CLI: |
162 |
| -```shell |
163 |
| -odo log |
164 |
| -``` |
| 68 | +1. Watch for changes in your local project |
165 | 69 |
|
166 |
| -It is also possible to disable the "hot test" mode of liberty:dev mode by re-running the `odo push` with the following argument: |
167 |
| -```shell |
168 |
| -odo push --run-command=run-test-off |
169 |
| -``` |
170 |
| - |
171 |
| -### DEBUG |
172 |
| - |
173 |
| -The Open Liberty stack has a built in "debug mode". This allows you to connect a debugger to your application running in your cluster. To invoke debug mode, issue the following: |
174 |
| - |
175 |
| -```shell |
176 |
| -odo push --debug |
177 |
| -odo debug port-forward |
178 |
| -``` |
179 |
| - |
180 |
| -These commands enable "debug" mode in the underlying Open Liberty server as well as forwarding the default odo debug port of 5858. Once complete, you can connect a debugger from your local workstation. |
181 |
| - |
182 |
| -Additionally, you can override the local port used for debugging with the following option on the `odo debug port-forward` command: |
183 |
| - |
184 |
| -```shell |
185 |
| -odo debug port-forward --local-port=7777 |
186 |
| -``` |
187 |
| - |
188 |
| - |
189 |
| -### TEST |
190 |
| - |
191 |
| -Once your application container is up and running after an `odo push`, you can force a run of any integration tests that you have for your project. The Open Liberty stack runs the Maven failsafe integration-test goal (`failsafe:integration-test`) to invoke your project's tests using the MicroShed Testing (MST) framework. |
192 |
| -
|
193 |
| -To do this, enter the following: |
194 |
| -
|
195 |
| -```shell |
196 |
| -odo test --show-log |
197 |
| -``` |
| 70 | + ```shell |
| 71 | + odo watch |
| 72 | + ``` |
198 | 73 |
|
199 |
| -## ODO deployment operations |
| 74 | +You can now begin developing your app! Changes will be detected and pushed automatically. |
200 | 75 |
|
201 |
| -### DEPLOY |
| 76 | +For more details on using the starter app, checkout https://github.com/OpenLiberty/application-stack/wiki/Using-the-Default-Starter-Application |
202 | 77 |
|
203 |
| -Once your development is done, you can "deploy" your code using the `odo deploy` command. This creates a production ready image for your application based on the official Open Liberty image in Dockerhub and deploys it to a specified namespace. |
| 78 | +## User Doc |
204 | 79 |
|
205 |
| -**NOTE!!!** This is currently included in PR https://github.com/openshift/odo/pull/3478. To use this support, the remote PR branch must be built locally. |
| 80 | +Checkout the application-stack [wiki](https://github.com/OpenLiberty/application-stack/wiki) for details on using the Open Liberty stack. |
206 | 81 |
|
207 |
| -<!-- Add link to deploy guide once completed --> |
| 82 | +## Contributing |
208 | 83 |
|
209 |
| -<!-- odo pipeline? --> |
| 84 | +Our [CONTRIBUTING](https://github.com/OpenLiberty/application-stack/blob/master/CONTRIBUTING.md) document contains details for submitting pull requests. |
210 | 85 |
|
211 | 86 | ## License
|
212 | 87 |
|
|
0 commit comments