Skip to content

Commit

Permalink
updated spring boot doc
Browse files Browse the repository at this point in the history
  • Loading branch information
naman-msft committed Dec 13, 2024
1 parent 22765d1 commit 937d70c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 56 deletions.
22 changes: 0 additions & 22 deletions pod.yaml

This file was deleted.

64 changes: 30 additions & 34 deletions scenarios/SpringBoot/spring-boot.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
# SpringBootDemo
Spring Boot application that we will deploy to Kubernetes clusters in all 3 clouds

# Building and deploying the docker image:
```bash
sudo apt-get install -y default-jdk maven
```
```bash
mvn clean install
```
```bash
mvn spring-boot:run
```
```bash
docker build -t spring-boot-demo.jar .
docker run -p 9091:8080 spring-boot-demo.jar
```
Spring Boot application that we will deploy to Kubernetes clusters in Azure.

# Deploying to VM

## Azure
## Deploying to VM

### Create and connect to the VM
Set up parameter variables:

```bash
export SUBSCRIPTION=ad70ac39-7cb2-4ed2-8678-f192bc4272b6 # customize this
export RESOURCE_GROUP=SpringBoot # customize this
export REGION=westus2 # customize this
export VM_NAME=springboot-vm
export VM_IMAGE=UbuntuLTS
export ADMIN_USERNAME=vm-admin-name # customize this
```

Log in and create VM:

```bash
export RANDOM_ID="$(openssl rand -hex 3)"
export RESOURCE_GROUP="SpringBoot$RANDOM_ID"
export REGION="westus2"

az group create --name ${RESOURCE_GROUP} --location ${REGION}
```

```bash
export VM_NAME="springboot-vm$RANDOM_ID"
export ADMIN_USERNAME="vm-admin-name$RANDOM_ID"
export VM_IMAGE="Ubuntu2204"

az vm create \
--resource-group ${RESOURCE_GROUP} \
--name ${VM_NAME} \
Expand All @@ -48,7 +33,7 @@ az vm create \
Store the VM IP address for later:

```bash
VM_IP_ADDRESS=`az vm show -d -g ${RESOURCE_GROUP} -n ${VM_NAME} --query publicIps -o tsv`
export VM_IP_ADDRESS=`az vm show -d -g ${RESOURCE_GROUP} -n ${VM_NAME} --query publicIps -o tsv`
```

Run the following to open port 8080 on the vm since SpringBoot uses it
Expand All @@ -60,17 +45,17 @@ az vm open-port --port 8080 --resource-group ${RESOURCE_GROUP} --name ${VM_NAME}
Connect to the VM:

```bash
ssh ${ADMIN_USERNAME}@${VM_IP_ADDRESS}
ssh -o StrictHostKeyChecking=no -t ${ADMIN_USERNAME}@${VM_IP_ADDRESS}
```

### Deploy the application

Install Java and maven needed for application

```bash
sudo apt update
sudo apt install default-jdk
sudo apt install maven
sudo apt-get update
sudo apt-get install default-jdk
sudo apt-get install maven
```

Now it's time to clone the project into the vm and give it proper permissions:
Expand All @@ -83,9 +68,20 @@ sudo chmod -R 777 /opt/SpringBootDemo/
```

Run and deploy the app

```bash
mvn clean install
mvn spring-boot:run
```

Finally go to http://[$VM_IP_ADDRESS]:8080 to confirm that it's working :D :D :D
### Verify the application

Finally, go to http://[$VM_IP_ADDRESS]:8080 to confirm that it's working :D :D :D

To verify if the application is running, you can use the `curl` command:

```bash
curl http://[$VM_IP_ADDRESS]:8080
```

If the application is running, you should see the HTML content of the Spring Boot application's home page.

0 comments on commit 937d70c

Please sign in to comment.