Skip to content

Commit

Permalink
On branch edburns-msft-eb-5297-pre-javaland-runthrough Successfully d…
Browse files Browse the repository at this point in the history
…eployed. (#8)

modified:   README.md

- Use tag to help prevent bitrot.

- Sort env vars alphabetically for easier diffing.

- Advise the reader to `--use-device-code`.

- Advise the reader to check the exit status with `$?`.

- Advise the reader to deploy the DB while the app is deploying.

- Various typos and ZSH escapes.

- When a string is a hostname, not a URL, call it a hostname.

Signed-off-by: Ed Burns <edburns@microsoft.com>
  • Loading branch information
edburns authored Apr 8, 2024
1 parent cc8b550 commit 42596d4
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ mkdir cargotracker-liberty-aks
DIR="$PWD/cargotracker-liberty-aks"
git clone https://github.com/Azure-Samples/cargotracker-liberty-aks.git ${DIR}/cargotracker
cd ${DIR}/cargotracker
git checkout 20240408
```
If you see a message about `detached HEAD state`, it is safe to ignore. It just means you have checked out a tag.
### Prepare your variables for deployments
Create a bash script with environment variables by making a copy of the supplied template:
Create a bash script with environment variables by making a copy of the supplied template. Customize the variables indicated.
```bash
cp ${DIR}/cargotracker/.scripts/setup-env-variables-template.sh ${DIR}/cargotracker/.scripts/setup-env-variables.sh
Expand Down Expand Up @@ -106,6 +110,7 @@ source ${DIR}/cargotracker/.scripts/setup-env-variables.sh
### Clone Liberty on AKS Bicep templates
```bash
cd ${DIR}
git clone https://github.com/WASdev/azure.liberty.aks ${DIR}/azure.liberty.aks
cd ${DIR}/azure.liberty.aks
Expand All @@ -119,7 +124,7 @@ cd ${DIR}
If you haven't already, sign into your Azure subscription by using the `az login` command and follow the on-screen directions.

```bash
az login
az login --use-device-code
```

If you have multiple Azure tenants associated with your Azure credentials, you must specify which tenant you want to sign in to. You can do this with the `--tenant` option. For example, `az login --tenant contoso.onmicrosoft.com`.
Expand Down Expand Up @@ -211,7 +216,13 @@ az deployment group validate \
--template-file ${DIR}/azure.liberty.aks/src/main/bicep/mainTemplate.bicep
```

The command should be completed without error. If there is, you must resolve it before moving on.
The command should be completed without error. If there is, you must resolve it before moving on. Verify the exit status from the command by examining shell's exit status. In POSIX environments, this is `$?`.
```bash
echo $?
```
The value must be **0**.
Next, invoke the template.
Expand All @@ -225,11 +236,11 @@ az deployment group create \
It takes more than 10 minutes to finish the deployment. The Open Liberty Operator is running in namespace `default`.
If you are using Azure Cloud Shell, and the terminal is disconnected, run source <path-to>/cargotracker/.scripts/setup-env-variables.sh to set the variables.
If you are using Azure Cloud Shell, and the terminal is disconnected, run `source <path-to>/cargotracker/.scripts/setup-env-variables.sh` to set the variables.
### Create an Azure Database for PostgreSQL instance
Use `az postgres server create` to provision a PostgreSQL instance on Azure. The data server allows access from Azure Services.
While the previous command runs, use `az postgres server create` to provision a PostgreSQL instance on Azure. The data server allows access from Azure Services.
```bash
az postgres server create \
Expand Down Expand Up @@ -276,7 +287,7 @@ WORKSPACE_ID=$(az monitor log-analytics workspace list -g ${RESOURCE_GROUP_NAME}
This quickstart uses Container Insights to monitor AKS. Enable it with the following commands.
```bash
AKS_NAME=$(az aks list -g ${RESOURCE_GROUP_NAME} --query [0].name -o tsv)
AKS_NAME=$(az aks list -g ${RESOURCE_GROUP_NAME} --query \[0\].name -o tsv)
az aks enable-addons \
--addons monitoring \
Expand Down Expand Up @@ -324,7 +335,7 @@ Now, it's ready to build Cargo Tracker.
mvn clean install -PopenLibertyOnAks --file ${DIR}/cargotracker/pom.xml
```
The war file locates at `${DIR}/cargotracker/target/cargo-tracker.war`.
The war file is created at `${DIR}/cargotracker/target/cargo-tracker.war`.
The following steps are to build a container image which will be deployed to AKS.
Expand All @@ -335,7 +346,7 @@ IMAGE_NAME=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' -
IMAGE_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec --file ${DIR}/cargotracker/pom.xml)
```
Run `ac acr built` command to build the container image.
Run `ac acr build` command to build the container image.
```bash
cd ${DIR}/cargotracker/target
Expand All @@ -345,7 +356,7 @@ az acr build -t ${IMAGE_NAME}:${IMAGE_VERSION} -r ${REGISTRY_NAME} .
The image is ready to deploy to AKS. Run the following command to connect to AKS cluster.
```bash
AKS_NAME=$(az aks list -g ${RESOURCE_GROUP_NAME} --query [0].name -o tsv)
AKS_NAME=$(az aks list -g ${RESOURCE_GROUP_NAME} --query \[0\].name -o tsv)
az aks get-credentials --resource-group ${RESOURCE_GROUP_NAME} --name $AKS_NAME
```
Expand All @@ -372,23 +383,23 @@ This section uses Application Insights and Azure Log Analytics to monitor Open L
#### Use Cargo Tracker and make a few HTTP calls
You can open Cargo Tracker in your web browser and follow [Appendix 1 - Exercise Cargo Tracker Functionality](#appendix-1---exercise-cargo-tracker-functionality) to make some calls.

Use the following commands to obtain URL of Cargo Tracker. When accessing the application, if you get "502 Bad Gateway" response, just wait a few minutes.
You can open Cargo Tracker in your web browser. Use the following commands to obtain URL of Cargo Tracker. When accessing the application, if you get "502 Bad Gateway" response, just wait a few minutes.
```bash
GATEWAY_PUBLICIP_ID=$(az network application-gateway list \
--resource-group ${RESOURCE_GROUP_NAME} \
--query '[0].frontendIPConfigurations[0].publicIPAddress.id' -o tsv)
GATEWAY_URL=$(az network public-ip show --ids ${GATEWAY_PUBLICIP_ID} --query 'dnsSettings.fqdn' -o tsv)
GATEWAY_HOSTNAME=$(az network public-ip show --ids ${GATEWAY_PUBLICIP_ID} --query 'dnsSettings.fqdn' -o tsv)
CARGO_TRACKER_URL="http://${GATEWAY_URL}/cargo-tracker/"
CARGO_TRACKER_URL="http://${GATEWAY_HOSTNAME}/cargo-tracker/"
echo "Cargo Tracker URL: ${CARGO_TRACKER_URL}"
```
Once you have the URL, follow [Appendix 1 - Exercise Cargo Tracker Functionality](#appendix-1---exercise-cargo-tracker-functionality) to make some calls.
You can also `curl` the REST API exposed by Cargo Tracker. It's strongly recommended you get familiar with Cargo Tracker with the above exercise.

The `/graph-traversal/shortest-path` REST API allows you to retrieve shortest path from origin to destination.
Expand Down Expand Up @@ -705,4 +716,4 @@ This job is to build app, push it to ACR and apply it to Open Liberty server run

## Appendix 2 - Learn more about Cargo Tracker

See [Eclipse Cargo Tracker - Applied Domain-Driven Design Blueprints for Jakarta EE](https://github.com/eclipse-ee4j/cargotracker/)
See [Eclipse Cargo Tracker - Applied Domain-Driven Design Blueprints for Jakarta EE](https://github.com/eclipse-ee4j/cargotracker/)

0 comments on commit 42596d4

Please sign in to comment.