Skip to content

Commit c905ddf

Browse files
Merge pull request #270989 from m-reza-rahman/patch-4
Simplify and bug fix.
2 parents f176844 + 022a617 commit c905ddf

File tree

1 file changed

+55
-38
lines changed

1 file changed

+55
-38
lines changed

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

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,28 @@ This article is intended to help you quickly get to deployment. Before going to
2929

3030
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
3131

32-
[!INCLUDE [azure-cli-prepare-your-environment.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)]
32+
## Prerequisites
3333

34-
> [!NOTE]
35-
> You can also execute this guidance from the [Azure Cloud Shell](/azure/cloud-shell/quickstart). This approach has all the prerequisite tools pre-installed, with the exception of Docker.
36-
>
37-
> :::image type="icon" source="~/reusable-content/ce-skilling/azure/media/cloud-shell/launch-cloud-shell-button.png" alt-text="Button to launch the Azure Cloud Shell." border="false" link="https://shell.azure.com":::
38-
39-
* Prepare a local machine with a Unix-like operating system installed (for example, Ubuntu, macOS, Windows Subsystem for Linux).
40-
* This article requires at least version 2.31.0 of Azure CLI.
34+
* Install the [Azure CLI](/cli/azure/install-azure-cli). If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see [How to run the Azure CLI in a Docker container](/cli/azure/run-azure-cli-docker).
35+
* Sign in to the Azure CLI by using the [az login](/cli/azure/reference-index#az-login) command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see [Sign in with the Azure CLI](/cli/azure/authenticate-azure-cli).
36+
* When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see [Use extensions with the Azure CLI](/cli/azure/azure-cli-extensions-overview).
37+
* Run [az version](/cli/azure/reference-index?#az-version) to find the version and dependent libraries that are installed. To upgrade to the latest version, run [az upgrade](/cli/azure/reference-index?#az-upgrade). This article requires at least version 2.31.0 of Azure CLI.
4138
* Install a Java SE implementation, version 17 or later. (for example, [Eclipse Open J9](https://www.eclipse.org/openj9/)).
4239
* Install [Maven](https://maven.apache.org/download.cgi) 3.5.0 or higher.
4340
* Install [Docker](https://docs.docker.com/get-docker/) for your OS.
41+
* Ensure [Git](https://git-scm.com) is installed.
4442
* Make sure you're assigned either the `Owner` role or the `Contributor` and `User Access Administrator` roles in the subscription. You can verify it by following steps in [List role assignments for a user or group](../role-based-access-control/role-assignments-list-portal.md#list-role-assignments-for-a-user-or-group).
4543

44+
> [!NOTE]
45+
> You can also execute this guidance from the [Azure Cloud Shell](/azure/cloud-shell/quickstart). This approach has all the prerequisite tools pre-installed, with the exception of Docker.
46+
>
47+
> :::image type="icon" source="~/reusable-content/ce-skilling/azure/media/cloud-shell/launch-cloud-shell-button.png" alt-text="Button to launch the Azure Cloud Shell." border="false" link="https://shell.azure.com":::
48+
4649
## Create a Liberty on AKS deployment using the portal
4750

4851
The following steps guide you to create a Liberty runtime on AKS. After completing these steps, you have an Azure Container Registry and an Azure Kubernetes Service cluster for deploying your containerized application.
4952

50-
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).
53+
1. Visit the [Azure portal](https://portal.azure.com/). In the search box at the top of the page, type *IBM Liberty on AKS*. 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).
5154

5255
1. Select **Create**.
5356

@@ -56,29 +59,27 @@ The following steps guide you to create a Liberty runtime on AKS. After completi
5659
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`.
5760
1. Select *East US* as **Region**.
5861

59-
Create environment variables in your shell for the resource group names for the cluster and the database.
62+
Create environment variables in your shell for the resource group name for the cluster.
6063

6164
### [Bash](#tab/in-bash)
6265

6366
```bash
6467
export RESOURCE_GROUP_NAME=<your-resource-group-name>
65-
export DB_RESOURCE_GROUP_NAME=<your-resource-group-name>
6668
```
6769

6870
### [PowerShell](#tab/in-powershell)
6971

7072
```powershell
7173
$Env:RESOURCE_GROUP_NAME="<your-resource-group-name>"
72-
$Env:DB_RESOURCE_GROUP_NAME="<your-resource-group-name>"
7374
```
7475

7576
---
7677

77-
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. The remaining values do not need to be changed from their default values.
78+
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. For our purposes, just keep all the defaults on this pane.
7879

7980
1. Select **Next**, enter the **Load Balancing** pane. Next to **Connect to Azure Application Gateway?** select **Yes**. This section lets you customize the following deployment options.
8081

81-
1. You can customize the **virtual network** and **subnet** into which the deployment will place the resources. The remaining values do not need to be changed from their default values.
82+
1. You can optionally customize the **virtual network** and **subnet** into which the deployment places the resources. The remaining values don't need to be changed from their default values.
8283
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).
8384
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.
8485

@@ -91,7 +92,7 @@ The following steps guide you to create a Liberty runtime on AKS. After completi
9192
9293
## Capture selected information from the deployment
9394
94-
If you navigated away from the **Deployment is in progress** page, the following steps will show you how to get back to that page. If you're still on the page that shows **Your deployment is complete**, you can skip to the third step.
95+
If you navigated away from the **Deployment is in progress** page, the following steps show you how to get back to that page. If you're still on the page that shows **Your deployment is complete**, go to the newly created resource group and skip to the third step.
9596

9697
1. In the upper left of any portal page, select the hamburger menu and select **Resource groups**.
9798
1. In the box with the text **Filter for any field**, enter the first few characters of the resource group you created previously. If you followed the recommended convention, enter your initials, then select the appropriate resource group.
@@ -100,7 +101,7 @@ If you navigated away from the **Deployment is in progress** page, the following
100101
1. Save aside the values for **Login server**, **Registry name**, **Username**, and **password**. You may use the copy icon at the right of each field to copy the value of that field to the system clipboard.
101102
1. Navigate again to the resource group into which you deployed the resources.
102103
1. In the **Settings** section, select **Deployments**.
103-
1. Select the bottom-most deployment in the list. The **Deployment name** will match the publisher ID of the offer. It will contain the string `ibm`.
104+
1. Select the bottom-most deployment in the list. The **Deployment name** matches the publisher ID of the offer. It contains the string `ibm`.
104105
1. In the left pane, select **Outputs**.
105106
1. Using the same copy technique as with the preceding values, save aside the values for the following outputs:
106107

@@ -109,15 +110,15 @@ If you navigated away from the **Deployment is in progress** page, the following
109110

110111
### [Bash](#tab/in-bash)
111112

112-
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.
113+
Paste the value of `appDeploymentTemplateYaml` or `appDeploymentYaml` into a Bash shell, append `| grep secretName`, and execute. This command outputs the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
113114

114115
### [PowerShell](#tab/in-powershell)
115116

116-
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.
117+
Paste the quoted string in `appDeploymentTemplateYaml` or `appDeploymentYaml` into a PowerShell (excluding the `| base64` portion), append `| ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) } | Select-String "secretName"`, and execute. This command outputs the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
117118
118119
---
119120
120-
These values will be used later in this article. Note that several other useful commands are listed in the outputs.
121+
These values are used later in this article. Note that several other useful commands are listed in the outputs.
121122
122123
> [!NOTE]
123124
> You may notice a similar output named **appDeploymentYaml**. The difference between output *appDeploymentTemplateYaml* and *appDeploymentYaml* is:
@@ -128,7 +129,23 @@ These values will be used later in this article. Note that several other useful
128129
129130
[!INCLUDE [create-azure-sql-database](includes/jakartaee/create-azure-sql-database.md)]
130131
131-
Now that the database and AKS cluster have been created, we can proceed to preparing AKS to host your Open Liberty application.
132+
Create environment variables in your shell for the resource group name for the database.
133+
134+
### [Bash](#tab/in-bash)
135+
136+
```bash
137+
export DB_RESOURCE_GROUP_NAME=<your-database-resource-group-name>
138+
```
139+
140+
### [PowerShell](#tab/in-powershell)
141+
142+
```powershell
143+
$Env:DB_RESOURCE_GROUP_NAME="<your-database-resource-group-name>"
144+
```
145+
146+
---
147+
148+
Now that the database and AKS cluster are created, we can proceed to preparing AKS to host your Open Liberty application.
132149
133150
## Configure and deploy the sample application
134151
@@ -138,7 +155,7 @@ Follow the steps in this section to deploy the sample application on the Liberty
138155
139156
Clone the sample code for this guide. The sample is on [GitHub](https://github.com/Azure-Samples/open-liberty-on-aks).
140157
141-
There are a few samples in the repository. We'll use *java-app/*. Here's the file structure of the application.
158+
There are a few samples in the repository. We use *java-app/*. Here's the file structure of the application.
142159
143160
#### [Bash](#tab/in-bash)
144161
@@ -160,7 +177,7 @@ git checkout 20240109
160177
161178
---
162179
163-
If you see a message about being in "detached HEAD" state, this message is safe to ignore. It just means you have checked out a tag.
180+
If you see a message about being in "detached HEAD" state, this message is safe to ignore. It just means you checked out a tag.
164181
165182
```
166183
java-app
@@ -192,14 +209,14 @@ In directory *liberty/config*, the *server.xml* file is used to configure the DB
192209
193210
### Build the project
194211
195-
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.
212+
Now that you 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.
196213
197214
#### [Bash](#tab/in-bash)
198215
199216
200217
```bash
201218
cd $BASE_DIR/java-app
202-
# The following variables will be used for deployment file generation into target.
219+
# The following variables are used for deployment file generation into target.
203220
export LOGIN_SERVER=<Azure-Container-Registry-Login-Server-URL>
204221
export REGISTRY_NAME=<Azure-Container-Registry-name>
205222
export USER_NAME=<Azure-Container-Registry-username>
@@ -218,16 +235,16 @@ mvn clean install
218235
```powershell
219236
cd $env:BASE_DIR\java-app
220237
221-
# The following variables will be used for deployment file generation into target.
222-
$Env:LOGIN_SERVER=<Azure-Container-Registry-Login-Server-URL>
223-
$Env:REGISTRY_NAME=<Azure-Container-Registry-name>
224-
$Env:USER_NAME=<Azure-Container-Registry-username>
225-
$Env:PASSWORD=<Azure-Container-Registry-password>
226-
$Env:DB_SERVER_NAME=<server-name>.database.windows.net
227-
$Env:DB_NAME=<database-name>
228-
$Env:DB_USER=<server-admin-login>@<server-name>
229-
$Env:DB_PASSWORD=<server-admin-password>
230-
$Env:INGRESS_TLS_SECRET=<ingress-TLS-secret-name>
238+
# The following variables are used for deployment file generation into target.
239+
$Env:LOGIN_SERVER="<Azure-Container-Registry-Login-Server-URL>"
240+
$Env:REGISTRY_NAME="<Azure-Container-Registry-name>"
241+
$Env:USER_NAME="<Azure-Container-Registry-username>"
242+
$Env:PASSWORD="<Azure-Container-Registry-password>"
243+
$Env:DB_SERVER_NAME="<server-name>.database.windows.net"
244+
$Env:DB_NAME="<database-name>"
245+
$Env:DB_USER="<server-admin-login>@<server-name>"
246+
$Env:DB_PASSWORD="<server-admin-password>"
247+
$Env:INGRESS_TLS_SECRET="<ingress-TLS-secret-name>"
231248
232249
mvn clean install
233250
```
@@ -238,7 +255,7 @@ mvn clean install
238255
239256
You can now run and test the project locally before deploying to Azure. For convenience, we use the `liberty-maven-plugin`. To learn more about the `liberty-maven-plugin`, see [Building a web application with Maven](https://openliberty.io/guides/maven-intro.html). For your application, you can do something similar using any other mechanism, such as your local IDE. You can also consider using the `liberty:devc` option intended for development with containers. You can read more about `liberty:devc` in the [Liberty docs](https://openliberty.io/docs/latest/development-mode.html#_container_support_for_dev_mode).
240257
241-
1. Start the application using `liberty:run`. `liberty:run` will also use the environment variables defined in the previous step.
258+
1. Start the application using `liberty:run`. `liberty:run` also uses the environment variables defined in the previous step.
242259
243260
#### [Bash](#tab/in-bash)
244261
@@ -344,7 +361,7 @@ Use the following steps to deploy and test the application:
344361
345362
1. Connect to the AKS cluster.
346363
347-
Paste the value of **cmdToConnectToCluster** into a Bash shell and execute.
364+
Paste the value of **cmdToConnectToCluster** into a shell and execute.
348365
349366
1. Apply the DB secret.
350367
@@ -364,7 +381,7 @@ Use the following steps to deploy and test the application:
364381
365382
---
366383
367-
You'll see the output `secret/db-secret-sql created`.
384+
You see the output `secret/db-secret-sql created`.
368385
369386
1. Apply the deployment file.
370387
@@ -427,7 +444,7 @@ Use the following steps to deploy and test the application:
427444
428445
Copy the value of **ADDRESS** from the output, this is the frontend public IP address of the deployed Azure Application Gateway.
429446
430-
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.
447+
1. Go to `https://<ADDRESS>` to test the application. For your convenience, this shell command creates an environment variable whose value you can paste straight into the browser.
431448
432449
#### [Bash](#tab/in-bash)
433450

0 commit comments

Comments
 (0)