Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
5659b78
new
Nov 11, 2021
725d2bd
commit
Nov 16, 2021
733dadb
commit
Nov 16, 2021
988832f
..
Nov 22, 2021
395f2ea
updated
Nov 22, 2021
25d1ec6
update
Nov 22, 2021
b5d3fc5
update
Nov 22, 2021
0f3d7d7
Delete Terraform directory
prathibhapadma Nov 22, 2021
dce519b
Create aks-cluster.tf
prathibhapadma Nov 22, 2021
b8942ac
Create outputs.tf
prathibhapadma Nov 22, 2021
7048ff0
Create terraform.tfvars
prathibhapadma Nov 22, 2021
94cc826
Create variables.tf
prathibhapadma Nov 22, 2021
6bb00dd
Create versions.tf
prathibhapadma Nov 22, 2021
fc84169
Create README.md
prathibhapadma Nov 22, 2021
8746488
Create terraform_doc.asciidoc
prathibhapadma Nov 22, 2021
1f63370
Update README.md
prathibhapadma Nov 22, 2021
d23a98b
Create run.sh
prathibhapadma Nov 22, 2021
35cb800
Update run.sh
prathibhapadma Nov 22, 2021
23450a2
Update run.sh
prathibhapadma Nov 22, 2021
5a47ab5
updated
prathibhapadma Nov 22, 2021
3b8fb83
Update versions.tf
prathibhapadma Nov 22, 2021
67f653f
Update terraform_doc.asciidoc
prathibhapadma Nov 23, 2021
52a71bf
terraform doc updated
prathibhapadma Nov 24, 2021
fc126cf
Update terraform_doc.asciidoc
prathibhapadma Nov 24, 2021
cb39e47
Update terraform_doc.asciidoc
prathibhapadma Nov 24, 2021
2eff054
Update deployment.yaml
prathibhapadma Nov 25, 2021
22fc6c4
Update terraform_doc.asciidoc
prathibhapadma Nov 25, 2021
846fab5
Delete terraform directory
prathibhapadma Nov 26, 2021
78e01cd
updated main file
prathibhapadma Nov 26, 2021
1df76c8
Create output.tf
prathibhapadma Nov 26, 2021
d9b17c2
Create provider.tf
prathibhapadma Nov 26, 2021
9763fb3
Create terraform.tfvars
prathibhapadma Nov 26, 2021
3a98f25
Create variables.tf
prathibhapadma Nov 26, 2021
26ce5e5
Create helm_release.tf
prathibhapadma Nov 26, 2021
7a08dc7
Create provider.tf
prathibhapadma Nov 26, 2021
cfe525a
Create terraform_doc.asciidoc
prathibhapadma Nov 26, 2021
373c63d
Create script_execute.sh
prathibhapadma Nov 26, 2021
e3b62f4
Create initial_setup_script.sh
prathibhapadma Nov 26, 2021
9d3f206
Delete charts directory
prathibhapadma Nov 26, 2021
5fde87b
Add files via upload
prathibhapadma Nov 26, 2021
281ab88
Update deployment.yaml
prathibhapadma Nov 26, 2021
881f324
Update helm_release.tf
prathibhapadma Nov 26, 2021
83cc80d
Update terraform_doc.asciidoc
prathibhapadma Nov 26, 2021
13ec802
Add files via upload
prathibhapadma Nov 26, 2021
6be41a9
Update terraform_doc.asciidoc
prathibhapadma Nov 29, 2021
f8d9a79
Update helm_release.tf
prathibhapadma Nov 29, 2021
7836c58
Update terraform_doc.asciidoc
prathibhapadma Nov 29, 2021
7e062c9
Delete zipkin-all-in-one-deployment.yaml
prathibhapadma Nov 30, 2021
cf7c421
Delete vmagent-deployment.yaml
prathibhapadma Nov 30, 2021
188ddd0
Delete victoriametrics-deployment.yaml
prathibhapadma Nov 30, 2021
2f3dc12
Add files via upload
prathibhapadma Dec 1, 2021
53bd422
Add files via upload
prathibhapadma Dec 1, 2021
f2a24d1
Delete initial_setup_script.sh
prathibhapadma Dec 1, 2021
568f520
Delete terraform.tfstate
prathibhapadma Dec 1, 2021
26ebfdb
Delete terraform.tfstate.backup
prathibhapadma Dec 1, 2021
6975c9f
Delete terraform.tfstate
prathibhapadma Dec 1, 2021
8d58f81
Delete terraform.tfstate.backup
prathibhapadma Dec 1, 2021
4ae2094
Update installation_setup_windows.ps1
prathibhapadma Dec 1, 2021
1b74d09
Add files via upload
prathibhapadma Dec 1, 2021
1ded641
Update terraform_doc.asciidoc
prathibhapadma Dec 1, 2021
3eb33df
Update terraform_doc.asciidoc
prathibhapadma Dec 1, 2021
350a9b4
Update terraform_doc.asciidoc
prathibhapadma Dec 1, 2021
02b7be4
Update terraform_doc.asciidoc
prathibhapadma Dec 1, 2021
65d0c19
Update terraform_doc.asciidoc
prathibhapadma Dec 2, 2021
edb59bf
Update terraform_doc.asciidoc
prathibhapadma Dec 2, 2021
9d7be2b
Update terraform_doc.asciidoc
prathibhapadma Dec 2, 2021
0ad380a
Update terraform_doc.asciidoc
prathibhapadma Dec 2, 2021
5182fe8
Update terraform_doc.asciidoc
prathibhapadma Dec 2, 2021
b047852
Updated
prathibhapadma Dec 2, 2021
7626999
updated
prathibhapadma Dec 2, 2021
f37f7bb
updated
prathibhapadma Dec 2, 2021
eaad1c9
Add files via upload
prathibhapadma Dec 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
402 changes: 201 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

278 changes: 137 additions & 141 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,141 +1,137 @@
# devon4quarkus cloud native reference project

This is the reference project of [devon4quarkus](https://github.com/devonfw/devon4quarkus).

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

## Database & Jaeger & Prometheus

The app uses data persistence and you need a working database to use it. We also use tracing and metrics collector.
There is a `docker-compose.yaml` in the root of this repo that provides all of them.
You can start the DB and Jaeger containers using simple cmd:
```
docker-compose up
```
If you want to use other DB, modify the params in `application.properties`

To access Jaeger UI(tracing): http://localhost:16686
To access Prometheus(metrics): http://localhost:9090/graph
To access health check of our app: http://localhost:8080/q/health

## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
```shell script
./mvnw compile quarkus:dev
```

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

## Running tests

You can run tests from your IDE or via Maven. Simply run `./mvnw test ` or `./mvnw package`

## Tkit quarkus

Adding tkit libs to our project gives us several new features. Check the logs for example, all our business methods are now logged and timed.
The REST API now handles exceptions gracefully(as JSON response), and we get server side pagination with very little effort.
Our tests are now real integration tests with real postgres DB, and are stuitable for CI envs.

## Access your REST endpoint

Go to http://localhost:8080/animals


## OpenAPI & Swagger UI

With your app running, go to http://localhost:8080/q/swagger-ui to see the Swagger UI visualizing your API. You can access the YAML OpenAPI schema under http://localhost:8080/q/openapi

## Packaging and running the application

The application can be packaged using:
```shell script
./mvnw package
```
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.

If you want to build an _über-jar_, execute the following command:
```shell script
./mvnw package -Dquarkus.package.type=uber-jar
```

The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.

## Creating a native executable

You can create a native executable using:
```shell script
./mvnw package -Pnative
```

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
./mvnw package -Pnative -Dquarkus.native.container-build=true
```

You can then execute your native executable with: `./target/demo-quarkus-1.0.0-SNAPSHOT-runner`

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.

## Maven settings

It is recommended to use vanilla maven settings (no custom mirror, proxy) for better performance. If you have modified your default settings `~/.m2/settings.xml` please revert it, or run the maven commands with the clean settings included in this project using `-s ./settings.xml`

## Deploy to kubernetes

Create your k3d cluster and registry
```shell
k3d registry create registry --port 5000
k3d cluster create -c k8s/dev.yaml
```

Package your app as docker container and push to local k3d registry:
> **_NOTE:_** Be sure to package your app as native before
```shell
docker build -f src/main/docker/Dockerfile.jvm . -t k3d-registry:5000/demo-quarkus:latest
docker push k3d-registry:5000/demo-quarkus:latest
```

If `push` fails because of unresolved host, you can add it manually (`c:\windows\system32\drivers\etc\hosts` on Windows or `/etc/hosts` on Linux)
```shell
127.0.0.1 k3d-registry
```

Then apply the k8s resources to your cluster(make sure your kubectl has the correct context first)

```shell
kubectl apply -f k8s/postgres-deployment.yaml
kubectl apply -f k8s/postgres-service.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/ingress.yaml
```

Give it a few moments and then go to http://demo-quarkus.localhost

## Helm

Check our helm chart and update dependencies.
```
helm lint helm/
helm dependency update helm/
```

Deploy helm chart in the k8s cluster
> **_NOTE:_** Be sure to remove your old resources
```shell
kubectl delete Service demo-quarkus
kubectl delete Deployment demo-quarkus
kubectl delete Ingress demo-quarkus
```
```
helm install demo-quarkus ./helm
helm list
```

We can also package helm as artefact for the helm repository:
```
helm package helm/
Successfully packaged chart and saved it to: .../demo-quarkus-1.0.0.tgz
```
# devon4quarkus cloud native reference project

This is the reference project of [devon4quarkus](https://github.com/devonfw/devon4quarkus).

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

## Database & Jaeger & Prometheus

The app uses data persistence and you need a working database to use it. We also use tracing and metrics collector.
There is a `docker-compose.yaml` in the root of this repo that provides all of them.
You can start the DB and Jaeger containers using simple cmd:
```
docker-compose up
```
If you want to use other DB, modify the params in `application.properties`

To access Jaeger UI(tracing): http://localhost:16686
To access Prometheus(metrics): http://localhost:9090/graph
To access health check of our app: http://localhost:8080/q/health

## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
```shell script
./mvnw compile quarkus:dev
```

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

## Running tests

You can run tests from your IDE or via Maven. Simply run `./mvnw test ` or `./mvnw package`

## Tkit quarkus

Adding tkit libs to our project gives us several new features. Check the logs for example, all our business methods are now logged and timed.
The REST API now handles exceptions gracefully(as JSON response), and we get server side pagination with very little effort.
Our tests are now real integration tests with real postgres DB, and are stuitable for CI envs.

## Access your REST endpoint

Go to http://localhost:8080/animals


## OpenAPI & Swagger UI

With your app running, go to http://localhost:8080/q/swagger-ui to see the Swagger UI visualizing your API. You can access the YAML OpenAPI schema under http://localhost:8080/q/openapi

## Packaging and running the application

The application can be packaged using:
```shell script
./mvnw package
```
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.

If you want to build an _über-jar_, execute the following command:
```shell script
./mvnw package -Dquarkus.package.type=uber-jar
```

The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.

## Creating a native executable

You can create a native executable using:
```shell script
./mvnw package -Pnative
```

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
./mvnw package -Pnative -Dquarkus.native.container-build=true
```

You can then execute your native executable with: `./target/demo-quarkus-1.0.0-SNAPSHOT-runner`

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.

## Maven settings

It is recommended to use vanilla maven settings (no custom mirror, proxy) for better performance. If you have modified your default settings `~/.m2/settings.xml` please revert it, or run the maven commands with the clean settings included in this project using `-s ./settings.xml`

## Deploy to kubernetes

To deploy the application, you need a Kubernetes cluster and a registry from which to pull the application image.

Package your app as docker container and push the image to your local registry:

```shell
docker build -f src/main/docker/Dockerfile.jvm . -t your-registry/demo-quarkus:latest
docker push your-registry/demo-quarkus:latest
```

Also enter the path to your registry in the `k8s/application-deployment.yaml` file so that Kubernetes knows where to get the image from. The location to change is marked with a "TODO" comment.

Then apply the k8s resources to your cluster (make sure your kubectl has the correct context first)

```shell
kubectl apply -f k8s/postgres-deployment.yaml
kubectl apply -f k8s/postgres-service.yaml
kubectl apply -f k8s/application-deployment.yaml
kubectl apply -f k8s/application-service.yaml
kubectl apply -f k8s/ingress.yaml
```

Give it a few moments and then open http://demo-quarkus.localhost/products/ in your browser.

## Helm

> **_NOTE:_** Be sure to remove your old resources first
```shell
kubectl delete -f k8s
```

First, in the `src/main/helm/values.yaml` file, specify the path to your registry from which you want to obtain the image.
Then you can deploy the application with the following command:

```shell
helm install demo-quarkus src/main/helm
```

This will deploy the application and the corresponding Postgres database.
Try it out by opening http://demo-quarkus.localhost/products/ in your browser.

To terminate the instances use the following command:
```shell
helm uninstall demo-quarkus
```

### OpenTelemetry integration

Quarkus can be easily configured to support OpenTelemetry features that can be used in combination with tools such as Jaeger or VictoriaMetrics to monitor traces and metrics.
To learn more about OpenTelemetry, see the devonfw architecture browser in the [chapter about OpenTelemetry](https://devonfw.com/website/pages/architectures/solutions/monitoring_openTelemetry/).

The `documentation` folder contains a guide with instructions on how to set up the application in combination with these tools.
45 changes: 45 additions & 0 deletions azure-terraform/Install-Terraform.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

Function Install-Terraform
{
# Ensure to run the function with administrator privilege
if (-not (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{ Write-Host -ForegroundColor Red -Object "!!! Please run as Administrator !!!"; return }

# Terrafrom download Url
$Url = 'https://www.terraform.io/downloads.html'

# Local path to download the terraform zip file
$DownloadPath = 'C:\Terraform\'

# Reg Key to set the persistent PATH
$RegPathKey = 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment'

# Create the local folder if it doesn't exist
if ((Test-Path -Path $DownloadPath) -eq $false) { $null = New-Item -Path $DownloadPath -ItemType Directory -Force }

# Download the Terraform exe in zip format
$Web = Invoke-WebRequest -Uri $Url
$FileInfo = $Web.Links | Where-Object href -match windows_amd64
$DownloadLink = $FileInfo.href
$FileName = Split-Path -Path $DownloadLink -Leaf
$DownloadFile = [string]::Concat( $DownloadPath, $FileName )
Invoke-RestMethod -Method Get -Uri $DownloadLink -OutFile $DownloadFile

# Extract & delete the zip file
Expand-Archive -Path $DownloadFile -DestinationPath $DownloadPath -Force
Remove-Item -Path $DownloadFile -Force

# Setting the persistent path in the registry if it is not set already
if ($DownloadPath -notin $($ENV:Path -split ';'))
{
$PathString = (Get-ItemProperty -Path $RegPathKey -Name PATH).Path
$PathString += ";$DownloadPath"
Set-ItemProperty -Path $RegPathKey -Name PATH -Value $PathString

# Setting the path for the current session
$ENV:Path += ";$DownloadPath"
}

# Verify the download
Invoke-Expression -Command "terraform version"
}
51 changes: 51 additions & 0 deletions azure-terraform/installation_setup_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

echo "Install Azure CLI...."
#Get packages needed for the install process:
sudo apt-get update
sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg

#Download and install the Microsoft signing key:
curl -sL https://packages.microsoft.com/keys/microsoft.asc |
gpg --dearmor |
sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

#Add the Azure CLI software repository
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
sudo tee /etc/apt/sources.list.d/azure-cli.list

#Update repository information and install the azure-cli package
sudo apt-get update
sudo apt-get install azure-cli

echo "az version"
az --version

echo "Install the Kubectl...."

az aks install-cli
kubectl version --client

echo "Install helm package..."
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
sudo helm version

#terraform Installation
echo "Install Terraform..."
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform

#terraform -help
terraform version

#terraform destroy
#terraform destroy --auto-approve


Loading