Skip to content

Commit 370e484

Browse files
josefreemajguo
authored andcommitted
update section for deploying Liberty using the azure portal and add powershell
1 parent cfec13a commit 370e484

File tree

2 files changed

+92
-24
lines changed

2 files changed

+92
-24
lines changed

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

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,27 @@ This article is intended to help you quickly get to deployment. Before going to
4545
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.
4646

4747
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).
48+
4849
1. Select **Create**.
49-
1. In the **Basics** pane, 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`. Select *East US* as **Region**. Select **Next** to **AKS** pane.
50-
1. 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 and select **Next** to **Load balancing** pane.
51-
1. Next to **Connect to Azure Application Gateway?** select **Yes**. This section lets you customize the following deployment options.
52-
1. You can customize the virtual network and subnet into which the deployment will place the resources. Leave these values at their defaults.
53-
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).
54-
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.
55-
![Screenshot of the enable cookie-based affinity checkbox.](./media/howto-deploy-java-liberty-app/enable-cookie-based-affinity.png)
56-
1. Select **Next** to **Operator and application** pane. This quickstart uses all defaults in this pane. However, it lets you customize the following deployment options.
57-
1. You can deploy WebSphere Liberty Operator by selecting **Yes** for option **IBM supported?**. Leaving the default **No** deploys Open Liberty Operator.
58-
1. You can deploy an application for your selected Operator by selecting **Yes** for option **Deploy an application?**. Leaving the default **No** doesn't deploy any application.
59-
1. Select **Review + create** to validate your selected options.
60-
1. When you see the message **Validation Passed**, select **Create**. The deployment may take up to 20 minutes.
50+
![Screenshot of create using Azure Marketplace Solution Template.](./media/howto-deploy-java-liberty-app/create-using-solution-template.png)
51+
52+
1. In the **Basics** pane
53+
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`.
54+
1. Select *East US* as **Region**.
55+
56+
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+
1. You can customize the **virtual network** and **subnet** into which the deployment will place the resources. Leave these values at their defaults.
60+
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)
63+
64+
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.
66+
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+
68+
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.
6169

6270
## Capture selected information from the deployment
6371

@@ -75,9 +83,15 @@ If you navigated away from the **Deployment is in progress** page, the following
7583
1. Using the same copy technique as with the preceding values, save aside the values for the following outputs:
7684

7785
* `cmdToConnectToCluster`
78-
* `appDeploymentTemplateYaml`
86+
* `appDeploymentTemplateYaml` if you select **No** to **Deploy an application?** when deploying the Marketplace offer; or `appDeploymentYaml` if you select **yes** to **Deploy an application?**.
87+
88+
### [Bash](#tab/in-bash)
89+
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+
91+
### [PowerShell](#tab/in-powershell)
92+
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.
7993

80-
1. Paste the value of `appDeploymentTemplateYaml` 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.
94+
---
8195

8296
These values will be used later in this article. Note that several other useful commands are listed in the outputs.
8397

@@ -111,7 +125,7 @@ Clone the sample code for this guide. The sample is on [GitHub](https://github.c
111125

112126
There are a few samples in the repository. We'll use *java-app/*. Here's the file structure of the application.
113127

114-
```azurecli-interactive
128+
```bash
115129
git clone https://github.com/Azure-Samples/open-liberty-on-aks.git
116130
cd open-liberty-on-aks
117131
git checkout 20240109
@@ -151,6 +165,7 @@ In directory *liberty/config*, the *server.xml* file is used to configure the DB
151165

152166
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.
153167

168+
### [Bash](#tab/in-bash)
154169
```bash
155170
cd <path-to-your-repo>/java-app
156171

@@ -167,6 +182,25 @@ export INGRESS_TLS_SECRET=<Ingress TLS secret name>
167182

168183
mvn clean install
169184
```
185+
### [PowerShell](#tab/in-powershell)
186+
```powershell
187+
cd <path-to-your-repo>/java-app
188+
189+
# 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>
199+
200+
mvn clean install
201+
202+
```
203+
---
170204

171205
### (Optional) Test your project locally
172206

@@ -199,14 +233,25 @@ You can now use the following steps to test the Docker image locally before depl
199233

200234
1. Run the image using the following command. Note we're using the environment variables defined previously.
201235

202-
```bash
203-
docker run -it --rm -p 9080:9080 \
204-
-e DB_SERVER_NAME=${DB_SERVER_NAME} \
205-
-e DB_NAME=${DB_NAME} \
206-
-e DB_USER=${DB_USER} \
207-
-e DB_PASSWORD=${DB_PASSWORD} \
236+
### [Bash](#tab/in-bash)
237+
```bash
238+
docker run -it --rm -p 9080:9080 \
239+
-e DB_SERVER_NAME=${DB_SERVER_NAME} \
240+
-e DB_NAME=${DB_NAME} \
241+
-e DB_USER=${DB_USER} \
242+
-e DB_PASSWORD=${DB_PASSWORD} \
208243
javaee-cafe:v1
209244
```
245+
### [PowerShell](#tab/in-powershell)
246+
```powershell
247+
docker run -it --rm -p 9080:9080 `
248+
-e DB_SERVER_NAME=${Env:DB_SERVER_NAME} `
249+
-e DB_NAME=${Env:DB_NAME} `
250+
-e DB_USER=${Env:DB_USER} `
251+
-e DB_PASSWORD=${Env:DB_PASSWORD} `
252+
javaee-cafe:v1
253+
```
254+
---
210255
211256
1. Once the container starts, go to `http://localhost:9080/` in your browser to access the application.
212257
@@ -216,11 +261,20 @@ You can now use the following steps to test the Docker image locally before depl
216261
217262
Upload the built image to the ACR created in the offer.
218263
264+
### [Bash](#tab/in-bash)
219265
```bash
220266
docker tag javaee-cafe:v1 ${LOGIN_SERVER}/javaee-cafe:v1
221267
docker login -u ${USER_NAME} -p ${PASSWORD} ${LOGIN_SERVER}
222268
docker push ${LOGIN_SERVER}/javaee-cafe:v1
223269
```
270+
### [PowerShell](#tab/in-powershell)
271+
```powershell
272+
docker tag javaee-cafe:v1 ${Env:LOGIN_SERVER}/javaee-cafe:v1
273+
docker login -u ${Env:USER_NAME} -p ${Env:PASSWORD} ${Env:LOGIN_SERVER}
274+
docker push ${Env:LOGIN_SERVER}/javaee-cafe:v1
275+
```
276+
---
277+
224278

225279
### Deploy and test the application
226280

@@ -274,21 +328,35 @@ The following steps deploy and test the application.
274328

275329
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.
276330

331+
### [Bash](#tab/in-bash)
277332
```bash
278-
export APP_URL=https://$(kubectl get ingress | grep javaee-cafe-cluster-agic-ingress | cut -d " " -f14)/
279-
echo $APP_URL
333+
export APP_URL=https://$(kubectl get ingress | grep javaee-cafe-cluster-agic-ingress | cut -d " " -f14)/
334+
echo $APP_URL
280335
```
336+
### [PowerShell](#tab/in-powershell)
337+
```powershell
338+
$APP_URL = "https://$(kubectl get ingress | Select-String 'javaee-cafe-cluster-agic-ingress' | ForEach-Object { $_.Line.Split(' ')[13] })/"
339+
$APP_URL
340+
```
341+
---
281342
282343
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.
283344
284345
## Clean up resources
285346
286347
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.
287348
288-
```azurecli-interactive
349+
### [Bash](#tab/in-bash)
350+
```bash
289351
az group delete --name $RESOURCE_GROUP_NAME --yes --no-wait
290352
az group delete --name <db-resource-group> --yes --no-wait
291353
```
354+
### [PowerShell](#tab/in-powershell)
355+
```powershell
356+
az group delete --name $Env:RESOURCE_GROUP_NAME --yes --no-wait
357+
az group delete --name <db-resource-group> --yes --no-wait
358+
```
359+
---
292360
293361
## Next steps
294362
57.2 KB
Loading

0 commit comments

Comments
 (0)