forked from MicrosoftDocs/executable-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added migrate from pod identity and spring boot docs
- Loading branch information
1 parent
2719071
commit 22765d1
Showing
3 changed files
with
284 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: httpbin-pod | ||
namespace: mynamespacefdbf2b | ||
labels: | ||
app: httpbin | ||
annotations: | ||
azure.workload.identity/inject-proxy-sidecar: "true" | ||
azure.workload.identity/proxy-sidecar-port: "8000" | ||
spec: | ||
serviceAccountName: myserviceaccountfdbf2b | ||
containers: | ||
- name: httpbin | ||
image: docker.io/kennethreitz/httpbin | ||
env: | ||
- name: IDENTITY_ENDPOINT | ||
value: "http://localhost:8000/metadata/identity/oauth2/token" | ||
- name: IDENTITY_HEADER | ||
value: "true" | ||
- name: IMDS_ENDPOINT | ||
value: "http://169.254.169.254" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# 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 | ||
``` | ||
|
||
# Deploying to VM | ||
|
||
## Azure | ||
|
||
### 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 | ||
az group create --name ${RESOURCE_GROUP} --location ${REGION} | ||
az vm create \ | ||
--resource-group ${RESOURCE_GROUP} \ | ||
--name ${VM_NAME} \ | ||
--image ${VM_IMAGE} \ | ||
--admin-username ${ADMIN_USERNAME} \ | ||
--generate-ssh-keys \ | ||
--public-ip-sku Standard --size standard_d4s_v3 | ||
``` | ||
|
||
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` | ||
``` | ||
|
||
Run the following to open port 8080 on the vm since SpringBoot uses it | ||
|
||
```bash | ||
az vm open-port --port 8080 --resource-group ${RESOURCE_GROUP} --name ${VM_NAME} --priority 1100 | ||
``` | ||
|
||
Connect to the VM: | ||
|
||
```bash | ||
ssh ${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 | ||
``` | ||
|
||
Now it's time to clone the project into the vm and give it proper permissions: | ||
|
||
```bash | ||
cd /opt | ||
sudo git clone https://github.com/dasha91/SpringBootDemo | ||
cd SpringBootDemo | ||
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 |
Oops, something went wrong.