Skip to content

Commit e86e733

Browse files
committed
edits; removed unnecessary images
1 parent 6e82513 commit e86e733

File tree

4 files changed

+59
-37
lines changed

4 files changed

+59
-37
lines changed

articles/aks/howto-deploy-java-liberty-app.md

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Deploy a Java application with Open Liberty/WebSphere Liberty on an Azure Kubernetes Service (AKS) cluster
33
recommendations: false
44
description: Deploy a Java application with Open Liberty/WebSphere Liberty on an Azure Kubernetes Service (AKS) cluster
5+
author: KarlErickson
6+
ms.author: edburns
57
ms.topic: how-to
68
ms.date: 12/21/2022
79
keywords: java, jakartaee, javaee, microprofile, open-liberty, websphere-liberty, aks, kubernetes
@@ -31,7 +33,7 @@ This article is intended to help you quickly get to deployment. Before going to
3133
* This article requires at least version 2.31.0 of Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
3234

3335
> [!NOTE]
34-
> This guidance can also be executed from a local developer command line with Azure CLI installed. To learn how to install the Azure CLI, see [How to install the Azure CLI](/cli/azure/install-azure-cli).
36+
> This guidance can also be executed from a local developer command line with Azure CLI installed. To learn how to install the Azure CLI, see [How to install the Azure CLI](/cli/azure/install-azure-cli).
3537
3638
* If running the commands in this guide locally (instead of Azure Cloud Shell):
3739
* Prepare a local machine with Unix-like operating system installed (for example, Ubuntu, Azure Linux, macOS, Windows Subsystem for Linux).
@@ -47,24 +49,25 @@ The following steps guide you to create a Liberty runtime on AKS. After completi
4749
1. Visit the [Azure portal](https://portal.azure.com/). In the search box at the top of the page, type *IBM WebSphere Liberty and Open Liberty on Azure Kubernetes Service*. When the suggestions start appearing, select the one and only match that appears in the **Marketplace** section. If you prefer, you can go directly to the offer with this shortcut link: [https://aka.ms/liberty-aks](https://aka.ms/liberty-aks).
4850

4951
1. Select **Create**.
50-
![Screenshot of create using Azure Marketplace Solution Template.](./media/howto-deploy-java-liberty-app/create-using-solution-template.png)
5152

5253
1. In the **Basics** pane
54+
5355
1. create a new resource group. Because resource groups must be unique within a subscription, pick a unique name. An easy way to have unique names is to use a combination of your initials, today's date, and some identifier. For example, `ejb0913-java-liberty-project-rg`.
5456
1. Select *East US* as **Region**.
5557

5658
1. Select **Next**, enter the **AKS** pane. This pane allows you to select an existing AKS cluster and Azure Container Registry (ACR), instead of causing the deployment to create a new one, if desired. This capability enables you to use the sidecar pattern, as shown in the [Azure architecture center](/azure/architecture/patterns/sidecar). You can also adjust the settings for the size and number of the virtual machines in the AKS node pool. Leave all other values at the defaults.
57-
58-
1. Select **Next**, enter the **Load Balancing** pane. Next to **Connect to Azure Application Gateway?** select **Yes**, then further configuration will be required.
59+
60+
1. Select **Next**, enter the **Load Balancing** pane. Next to **Connect to Azure Application Gateway?** select **Yes**, then further configuration will be required.
61+
5962
1. You can customize the **virtual network** and **subnet** into which the deployment will place the resources. Leave these values at their defaults.
6063
1. You can provide the **TLS/SSL certificate** presented by the Azure Application Gateway. Leave the values at the default to cause the offer to generate a self-signed certificate. Don't go to production using a self-signed certificate. For more information about self-signed certificates, see [Create a self-signed public certificate to authenticate your application](../active-directory/develop/howto-create-self-signed-certificate.md).
61-
1. You can enable **cookie based affinity**, also known as sticky sessions. We want sticky sessions enabled for this article, so ensure this option is selected.
62-
![Screenshot of the enable cookie-based affinity checkbox.](./media/howto-deploy-java-liberty-app/enable-cookie-based-affinity.png)
64+
1. You can select **Enable cookie based affinity**, also known as sticky sessions. We want sticky sessions enabled for this article, so ensure this option is selected.
6365

6466
1. Select **Next**, enter the **Operator and application** pane. Leave these values at their defaults.
65-
1. **IBM Supported?** if **Yes**, you select to deploy IBM WebSphere Liberty Operator; if **No**, you select to deploy Open Liberty Operator.
67+
68+
1. **IBM Supported?** if **Yes**, you select to deploy IBM WebSphere Liberty Operator; if **No**, you select to deploy Open Liberty Operator.
6669
1. **Deploy an application?** if **Yes**, you may select to deploy your own application image which need to be public and accessible without credential; or select to deploy the Open Liberty sample image.
67-
70+
6871
1. Select **Review + create** to validate your selected options. In the ***Review + create** pane, when you see **Create** light up after validation pass, select **Create**. The deployment may take up to 20 minutes.
6972

7073
## Capture selected information from the deployment
@@ -86,9 +89,11 @@ If you navigated away from the **Deployment is in progress** page, the following
8689
* `appDeploymentTemplateYaml` if you select **No** to **Deploy an application?** when deploying the Marketplace offer; or `appDeploymentYaml` if you select **yes** to **Deploy an application?**.
8790

8891
### [Bash](#tab/in-bash)
92+
8993
Paste the value of `appDeploymentTemplateYaml` or `appDeploymentYaml` into a Bash shell, append `| grep secretName`, and execute. This command will output the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
90-
94+
9195
### [PowerShell](#tab/in-powershell)
96+
9297
Paste the quoted string in `appDeploymentTemplateYaml` or `appDeploymentYaml` into a PowerShell, append `| ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) } | Select-String "secretName"`, and execute. This command will output the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
9398

9499
---
@@ -111,7 +116,7 @@ The following steps guide you through creating an Azure SQL Database single data
111116
>
112117
> At the **Networking** step, set **Connectivity method** to **Public endpoint**, **Allow Azure services and resources to access this server** to **Yes**, and **Add current client IP address** to **Yes**.
113118
>
114-
> ![Screenshot of configuring SQL database networking.](./media/howto-deploy-java-liberty-app/create-sql-database-networking.png)
119+
> :::image type="content" source="media/howto-deploy-java-liberty-app/create-sql-database-networking.png" alt-text="Screenshot of the Azure portal that shows the Networking tab of the Create SQL Database page with the Connectivity method and Firewall rules settings highlighted." lightbox="media/howto-deploy-java-liberty-app/create-sql-database-networking.png":::
115120
116121
Now that the database and AKS cluster have been created, we can proceed to preparing AKS to host your Open Liberty application.
117122

@@ -166,40 +171,44 @@ In directory *liberty/config*, the *server.xml* file is used to configure the DB
166171
Now that you've gathered the necessary properties, you can build the application. The POM file for the project reads many variables from the environment. As part of the Maven build, these variables are used to populate values in the YAML files located in *src/main/aks*. You can do something similar for your application outside Maven if you prefer.
167172

168173
### [Bash](#tab/in-bash)
174+
169175
```bash
170176
cd <path-to-your-repo>/java-app
171177

172178
# The following variables will be used for deployment file generation into target.
173-
export LOGIN_SERVER=<Azure_Container_Registry_Login_Server_URL>
174-
export REGISTRY_NAME=<Azure_Container_Registry_Name>
175-
export USER_NAME=<Azure_Container_Registry_Username>
176-
export PASSWORD=<Azure_Container_Registry_Password>
177-
export DB_SERVER_NAME=<Server name>.database.windows.net
178-
export DB_NAME=<Database name>
179-
export DB_USER=<Server admin login>@<Server name>
180-
export DB_PASSWORD=<Server admin password>
181-
export INGRESS_TLS_SECRET=<Ingress TLS secret name>
179+
export LOGIN_SERVER=<Azure-Container-Registry-Login-Server-URL>
180+
export REGISTRY_NAME=<Azure-Container-Registry-name>
181+
export USER_NAME=<Azure-Container-Registry-username>
182+
export PASSWORD=<Azure-Container-Registry-password>
183+
export DB_SERVER_NAME=<server-name>.database.windows.net
184+
export DB_NAME=<database-name>
185+
export DB_USER=<server-admin-login>@<server-name>
186+
export DB_PASSWORD=<server-admin-password>
187+
export INGRESS_TLS_SECRET=<ingress-TLS-secret-name>
182188

183189
mvn clean install
184190
```
191+
185192
### [PowerShell](#tab/in-powershell)
193+
186194
```powershell
187195
cd <path-to-your-repo>/java-app
188196
189197
# The following variables will be used for deployment file generation into target.
190-
$Env:LOGIN_SERVER=<Azure_Container_Registry_Login_Server_URL>
191-
$Env:REGISTRY_NAME=<Azure_Container_Registry_Name>
192-
$Env:USER_NAME=<Azure_Container_Registry_Username>
193-
$Env:PASSWORD=<Azure_Container_Registry_Password>
194-
$Env:DB_SERVER_NAME=<Server name>.database.windows.net
195-
$Env:DB_NAME=<Database name>
196-
$Env:DB_USER=<Server admin login>@<Server name>
197-
$Env:DB_PASSWORD=<Server admin password>
198-
$Env:INGRESS_TLS_SECRET=<Ingress TLS secret name>
198+
$Env:LOGIN_SERVER=<Azure-Container-Registry-Login-Server-URL>
199+
$Env:REGISTRY_NAME=<Azure-Container-Registry-name>
200+
$Env:USER_NAME=<Azure-Container-Registry-username>
201+
$Env:PASSWORD=<Azure-Container-Registry-password>
202+
$Env:DB_SERVER_NAME=<server-name>.database.windows.net
203+
$Env:DB_NAME=<database-name>
204+
$Env:DB_USER=<server-admin-login>@<server-name>
205+
$Env:DB_PASSWORD=<server-admin-password>
206+
$Env:INGRESS_TLS_SECRET=<ingress-TLS-secret-name>
199207
200208
mvn clean install
201209
202210
```
211+
203212
---
204213

205214
### (Optional) Test your project locally
@@ -219,7 +228,7 @@ You can now run and test the project locally before deploying to Azure. For conv
219228

220229
### Build image for AKS deployment
221230

222-
You can now run the `docker build` command to build the image.
231+
You can now run the `docker build` command to build the image.
223232

224233
```bash
225234
cd <path-to-your-repo>/java-app/target
@@ -234,6 +243,7 @@ You can now use the following steps to test the Docker image locally before depl
234243
1. Run the image using the following command. Note we're using the environment variables defined previously.
235244

236245
### [Bash](#tab/in-bash)
246+
237247
```bash
238248
docker run -it --rm -p 9080:9080 \
239249
-e DB_SERVER_NAME=${DB_SERVER_NAME} \
@@ -242,7 +252,9 @@ You can now use the following steps to test the Docker image locally before depl
242252
-e DB_PASSWORD=${DB_PASSWORD} \
243253
javaee-cafe:v1
244254
```
255+
245256
### [PowerShell](#tab/in-powershell)
257+
246258
```powershell
247259
docker run -it --rm -p 9080:9080 `
248260
-e DB_SERVER_NAME=${Env:DB_SERVER_NAME} `
@@ -251,6 +263,7 @@ You can now use the following steps to test the Docker image locally before depl
251263
-e DB_PASSWORD=${Env:DB_PASSWORD} `
252264
javaee-cafe:v1
253265
```
266+
254267
---
255268

256269
1. Once the container starts, go to `http://localhost:9080/` in your browser to access the application.
@@ -262,23 +275,26 @@ You can now use the following steps to test the Docker image locally before depl
262275
Upload the built image to the ACR created in the offer.
263276

264277
### [Bash](#tab/in-bash)
278+
265279
```bash
266280
docker tag javaee-cafe:v1 ${LOGIN_SERVER}/javaee-cafe:v1
267281
docker login -u ${USER_NAME} -p ${PASSWORD} ${LOGIN_SERVER}
268282
docker push ${LOGIN_SERVER}/javaee-cafe:v1
269283
```
284+
270285
### [PowerShell](#tab/in-powershell)
286+
271287
```powershell
272288
docker tag javaee-cafe:v1 ${Env:LOGIN_SERVER}/javaee-cafe:v1
273289
docker login -u ${Env:USER_NAME} -p ${Env:PASSWORD} ${Env:LOGIN_SERVER}
274290
docker push ${Env:LOGIN_SERVER}/javaee-cafe:v1
275291
```
276-
---
277292

293+
---
278294

279295
### Deploy and test the application
280296

281-
The following steps deploy and test the application.
297+
Use the following steps to deploy and test the application:
282298

283299
1. Connect to the AKS cluster.
284300

@@ -299,15 +315,13 @@ The following steps deploy and test the application.
299315
kubectl apply -f openlibertyapplication-agic.yaml
300316
```
301317

302-
1. Wait for the pods to be restarted.
303-
304-
Wait until all pods are restarted successfully using the following command.
318+
1. Wait until all pods are restarted successfully by using the following command:
305319

306320
```bash
307321
kubectl get pods --watch
308322
```
309323

310-
You should see output similar to the following to indicate that all the pods are running.
324+
You should see output similar to the following example to indicate that all the pods are running:
311325

312326
```output
313327
NAME READY STATUS RESTARTS AGE
@@ -325,19 +339,23 @@ The following steps deploy and test the application.
325339
```
326340

327341
Copy the value of **ADDRESS** from the output, this is the frontend public IP address of the deployed Azure Application Gateway.
328-
342+
329343
1. Go to `https://<ADDRESS>` to test the application. For your convenience, this shell command will create an environment variable whose value you can paste straight into the browser.
330-
344+
331345
### [Bash](#tab/in-bash)
346+
332347
```bash
333348
export APP_URL=https://$(kubectl get ingress | grep javaee-cafe-cluster-agic-ingress | cut -d " " -f14)/
334349
echo $APP_URL
335350
```
351+
336352
### [PowerShell](#tab/in-powershell)
353+
337354
```powershell
338355
$APP_URL = "https://$(kubectl get ingress | Select-String 'javaee-cafe-cluster-agic-ingress' | ForEach-Object { $_.Line.Split(' ')[13] })/"
339356
$APP_URL
340357
```
358+
341359
---
342360
343361
If the web page doesn't render correctly or returns a `502 Bad Gateway` error, that's because the app is still starting in the background. Wait for a few minutes and then try again.
@@ -347,15 +365,19 @@ The following steps deploy and test the application.
347365
To avoid Azure charges, you should clean up unnecessary resources. When the cluster is no longer needed, use the [az group delete](/cli/azure/group#az-group-delete) command to remove the resource group, container service, container registry, and all related resources.
348366
349367
### [Bash](#tab/in-bash)
368+
350369
```bash
351370
az group delete --name $RESOURCE_GROUP_NAME --yes --no-wait
352371
az group delete --name <db-resource-group> --yes --no-wait
353372
```
373+
354374
### [PowerShell](#tab/in-powershell)
375+
355376
```powershell
356377
az group delete --name $Env:RESOURCE_GROUP_NAME --yes --no-wait
357378
az group delete --name <db-resource-group> --yes --no-wait
358379
```
380+
359381
---
360382
361383
## Next steps
-24.1 KB
Loading
Binary file not shown.

0 commit comments

Comments
 (0)