miércoles, 18 de noviembre de 2026

Create a Unit service on Linux (systemd) logging Datetime

CreateAServicedlogDatetime.md

Creating a Unit service en Linux (systemd)

logging DateTime with start, stop options

references:
man systemd.service

Unit priority
1.- /etc/systemd/system
2.- /run/systemd/system
3.- /lib/systemd/system

/etc/systemd/system user create his service user
/etc/systemd/user user create his service user (here don’t find the service)
/lib/systemd/system installed packages, standard systemd unit files
/usr/lib/systemd/system from locally installed packages (eg. via apt-get)
/run/systemd/system runtime generated or transient

To see the Current Unit Services

sudo systemctl list-units
sudo systemctl list-units --type target --all
sudo systemctl list-units --type service --all
sudo systemctl list-unit-files

See the types of [service]s in ...
grep 'Type=' /etc/systemd/system/*.service

Create our service

Create the bash script

vi helloworldd

#!/bin/bash

function hellostart() {
  while [ 1 ]
    do
    echo Hello World $(date)
    sleep 10
    done
}

function hellostop() {
  killall $(basename $0)
}

case "$1" in
  start)
    hellostart
  ;;
  stop)
    hellostop
  ;;
esac

Copy the script in user scripts directory

cp helloworldd /usr/local/sbin/  

create de unit systemd service

vi helloworldd.service


[Unit]
Description=Hello World Service
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/local/sbin/helloworldd start
ExecStop=/usr/local/sbin/helloworldd stop
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

copy to the units services directory

cp helloworldd.service /etc/sytemd/system/           

Start and Stop the service

sudo systemctl start helloworldd.service 
orangepi@orangepi4pro:~$ sudo systemctl status helloworldd.service 
● helloworldd.service - Hello World Service
     Loaded: loaded (/etc/systemd/system/helloworldd.service; disabled; preset: enabled)
     Active: active (running) since Wed 2026-11-18 17:38:27 CST; 1s ago
 Invocation: 49287eb900f345b0b152437313844df1
   Main PID: 5818 (helloworldd)
      Tasks: 2 (limit: 4536)
     Memory: 536K (peak: 1.7M)
        CPU: 25ms
     CGroup: /system.slice/helloworldd.service
             ├─5818 /bin/bash /usr/local/sbin/helloworldd start
             └─5820 sleep 10

Nov 18 17:38:27 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 17:38:27 orangepi4pro helloworldd[5818]: Hello World Wed Nov 18 05:38:27 PM CST 2026
orangepi@orangepi4pro:~$ sudo systemctl stop helloworldd.service 
orangepi@orangepi4pro:~$ sudo systemctl status helloworldd.service 
× helloworldd.service - Hello World Service
     Loaded: loaded (/etc/systemd/system/helloworldd.service; disabled; preset: enabled)
     Active: failed (Result: signal) since Wed 2026-11-18 17:38:40 CST; 2s ago
   Duration: 12.836s
 Invocation: 49287eb900f345b0b152437313844df1
    Process: 5818 ExecStart=/usr/local/sbin/helloworldd start (code=killed, signal=TERM)
    Process: 5833 ExecStop=/usr/local/sbin/helloworldd stop (code=killed, signal=TERM)
   Main PID: 5818 (code=killed, signal=TERM)
   Mem peak: 2.2M
        CPU: 67ms

Nov 18 17:38:27 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 17:38:27 orangepi4pro helloworldd[5818]: Hello World Wed Nov 18 05:38:27 PM CST 2026
Nov 18 17:38:37 orangepi4pro helloworldd[5818]: Hello World Wed Nov 18 05:38:37 PM CST 2026
Nov 18 17:38:40 orangepi4pro systemd[1]: Stopping helloworldd.service - Hello World Service...
Nov 18 17:38:40 orangepi4pro systemd[1]: helloworldd.service: Control process exited, code=killed, status=15/TERM
Nov 18 17:38:40 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'signal'.
Nov 18 17:38:40 orangepi4pro systemd[1]: Stopped helloworldd.service - Hello World Service.

journalctl

sudo journalctl -u helloworldd.service 

Nov 18 16:17:23 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'exit-code'.
Nov 18 16:19:06 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 16:19:06 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:19:06 PM CST 2026
Nov 18 16:19:16 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:19:16 PM CST 2026
Nov 18 16:19:26 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:19:26 PM CST 2026
Nov 18 16:19:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:19:37 PM CST 2026
Nov 18 16:19:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:19:47 PM CST 2026
Nov 18 16:19:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:19:57 PM CST 2026
Nov 18 16:20:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:20:07 PM CST 2026
Nov 18 16:20:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:20:17 PM CST 2026
Nov 18 16:20:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:20:27 PM CST 2026
Nov 18 16:20:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:20:37 PM CST 2026
Nov 18 16:20:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:20:47 PM CST 2026
Nov 18 16:20:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:20:57 PM CST 2026
Nov 18 16:21:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:21:07 PM CST 2026
Nov 18 16:21:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:21:17 PM CST 2026
Nov 18 16:21:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:21:27 PM CST 2026
Nov 18 16:21:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:21:37 PM CST 2026
Nov 18 16:21:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:21:47 PM CST 2026
Nov 18 16:21:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:21:57 PM CST 2026
Nov 18 16:22:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:22:07 PM CST 2026
Nov 18 16:22:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:22:17 PM CST 2026
Nov 18 16:22:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:22:27 PM CST 2026
Nov 18 16:22:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:22:37 PM CST 2026
Nov 18 16:22:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:22:47 PM CST 2026
Nov 18 16:22:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:22:57 PM CST 2026
Nov 18 16:23:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:23:07 PM CST 2026
Nov 18 16:23:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:23:17 PM CST 2026
Nov 18 16:23:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:23:27 PM CST 2026
Nov 18 16:23:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:23:37 PM CST 2026
Nov 18 16:23:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:23:47 PM CST 2026
Nov 18 16:23:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:23:57 PM CST 2026
Nov 18 16:24:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:24:07 PM CST 2026
Nov 18 16:24:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:24:17 PM CST 2026
Nov 18 16:24:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:24:27 PM CST 2026
Nov 18 16:24:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:24:37 PM CST 2026
Nov 18 16:24:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:24:47 PM CST 2026
Nov 18 16:24:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:24:57 PM CST 2026
Nov 18 16:25:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:25:07 PM CST 2026
Nov 18 16:25:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:25:17 PM CST 2026
Nov 18 16:25:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:25:27 PM CST 2026
Nov 18 16:25:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:25:37 PM CST 2026
Nov 18 16:25:47 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:25:47 PM CST 2026
Nov 18 16:25:57 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:25:57 PM CST 2026
Nov 18 16:26:07 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:26:07 PM CST 2026
Nov 18 16:26:17 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:26:17 PM CST 2026
Nov 18 16:26:27 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:26:27 PM CST 2026
Nov 18 16:26:37 orangepi4pro helloworldd[3971]: Hello World Wed Nov 18 04:26:37 PM CST 2026
Nov 18 16:26:38 orangepi4pro systemd[1]: Stopping helloworldd.service - Hello World Service...
Nov 18 16:26:39 orangepi4pro systemd[1]: helloworldd.service: Control process exited, code=killed, status=15/TERM
Nov 18 16:26:39 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'signal'.
Nov 18 16:26:39 orangepi4pro systemd[1]: Stopped helloworldd.service - Hello World Service.
Nov 18 16:42:28 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 16:42:28 orangepi4pro helloworldd[4493]: Hello World Wed Nov 18 04:42:28 PM CST 2026
Nov 18 16:42:38 orangepi4pro helloworldd[4493]: Hello World Wed Nov 18 04:42:38 PM CST 2026
Nov 18 16:42:48 orangepi4pro helloworldd[4493]: Hello World Wed Nov 18 04:42:48 PM CST 2026
Nov 18 16:42:58 orangepi4pro helloworldd[4493]: Hello World Wed Nov 18 04:42:58 PM CST 2026
Nov 18 16:43:08 orangepi4pro helloworldd[4493]: Hello World Wed Nov 18 04:43:08 PM CST 2026
Nov 18 16:43:09 orangepi4pro systemd[1]: Stopping helloworldd.service - Hello World Service...
Nov 18 16:43:09 orangepi4pro systemd[1]: helloworldd.service: Control process exited, code=killed, status=15/TERM
Nov 18 16:43:09 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'signal'.
Nov 18 16:43:09 orangepi4pro systemd[1]: Stopped helloworldd.service - Hello World Service.
Nov 18 16:58:52 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 16:58:52 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:58:52 PM CST 2026
Nov 18 16:59:02 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:59:02 PM CST 2026
Nov 18 16:59:12 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:59:12 PM CST 2026
Nov 18 16:59:22 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:59:22 PM CST 2026
Nov 18 16:59:32 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:59:32 PM CST 2026
Nov 18 16:59:42 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:59:42 PM CST 2026
Nov 18 16:59:52 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 04:59:52 PM CST 2026
Nov 18 17:00:02 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:00:02 PM CST 2026
Nov 18 17:00:12 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:00:12 PM CST 2026
Nov 18 17:00:22 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:00:22 PM CST 2026
Nov 18 17:00:32 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:00:32 PM CST 2026
Nov 18 17:00:42 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:00:42 PM CST 2026
Nov 18 17:00:52 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:00:52 PM CST 2026
Nov 18 17:01:02 orangepi4pro helloworldd[4980]: Hello World Wed Nov 18 05:01:02 PM CST 2026
Nov 18 17:01:08 orangepi4pro systemd[1]: Stopping helloworldd.service...
Nov 18 17:01:08 orangepi4pro systemd[1]: helloworldd.service: Deactivated successfully.
Nov 18 17:01:08 orangepi4pro systemd[1]: Stopped helloworldd.service.
Nov 18 17:24:11 orangepi4pro systemd[1]: /etc/systemd/system/helloworldd.service:9: Failed to parse TimeoutStopSec=infiniy, ignoring: Invalid argument
Nov 18 17:37:19 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 17:37:19 orangepi4pro helloworldd[5764]: Hello World Wed Nov 18 05:37:19 PM CST 2026
Nov 18 17:37:29 orangepi4pro helloworldd[5764]: Hello World Wed Nov 18 05:37:29 PM CST 2026
Nov 18 17:37:39 orangepi4pro helloworldd[5764]: Hello World Wed Nov 18 05:37:39 PM CST 2026
Nov 18 17:37:49 orangepi4pro helloworldd[5764]: Hello World Wed Nov 18 05:37:49 PM CST 2026
Nov 18 17:37:59 orangepi4pro helloworldd[5764]: Hello World Wed Nov 18 05:37:59 PM CST 2026
Nov 18 17:38:00 orangepi4pro systemd[1]: Stopping helloworldd.service - Hello World Service...
Nov 18 17:38:01 orangepi4pro systemd[1]: helloworldd.service: Control process exited, code=killed, status=15/TERM
Nov 18 17:38:01 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'signal'.
Nov 18 17:38:01 orangepi4pro systemd[1]: Stopped helloworldd.service - Hello World Service.
Nov 18 17:38:27 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 17:38:27 orangepi4pro helloworldd[5818]: Hello World Wed Nov 18 05:38:27 PM CST 2026
Nov 18 17:38:37 orangepi4pro helloworldd[5818]: Hello World Wed Nov 18 05:38:37 PM CST 2026
Nov 18 17:38:40 orangepi4pro systemd[1]: Stopping helloworldd.service - Hello World Service...
Nov 18 17:38:40 orangepi4pro systemd[1]: helloworldd.service: Control process exited, code=killed, status=15/TERM
Nov 18 17:38:40 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'signal'.
Nov 18 17:38:40 orangepi4pro systemd[1]: Stopped helloworldd.service - Hello World Service.
Nov 18 17:51:31 orangepi4pro systemd[1]: Started helloworldd.service - Hello World Service.
Nov 18 17:51:32 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:51:32 PM CST 2026
Nov 18 17:51:42 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:51:42 PM CST 2026
Nov 18 17:51:52 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:51:52 PM CST 2026
Nov 18 17:52:02 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:52:02 PM CST 2026
Nov 18 17:52:12 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:52:12 PM CST 2026
Nov 18 17:52:22 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:52:22 PM CST 2026
Nov 18 17:52:32 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:52:32 PM CST 2026
Nov 18 17:52:42 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:52:42 PM CST 2026
Nov 18 17:52:52 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:52:52 PM CST 2026
Nov 18 17:53:02 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:53:02 PM CST 2026
Nov 18 17:53:12 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:53:12 PM CST 2026
Nov 18 17:53:22 orangepi4pro helloworldd[6072]: Hello World Wed Nov 18 05:53:22 PM CST 2026
Nov 18 17:53:24 orangepi4pro systemd[1]: Stopping helloworldd.service - Hello World Service...
Nov 18 17:53:24 orangepi4pro systemd[1]: helloworldd.service: Control process exited, code=killed, status=15/TERM
Nov 18 17:53:24 orangepi4pro systemd[1]: helloworldd.service: Failed with result 'signal'.
Nov 18 17:53:24 orangepi4pro systemd[1]: Stopped helloworldd.service - Hello World Service.

To see just the last 10 lines

journalctl -u helloworldd -n 10

miércoles, 8 de julio de 2026

A Vision of Web Application Security 2

  A Vision of Web Application Security  2


Configuration for a Local Web Server


  An schema where the Web Server is installed in the Local Machine require an a browser like Firefox that premit configure his proxy to point the BurpSuite proxy, use the FoxyProxy Extension in order to enable the flow to the local proxy address, in this case 127.0.0.1



The extension is added and then configured to 127.0.0.1:8080


Now we can run a web server in a Docker Container on Local Machine no test the proxy to de local server.


Test a Request to the local server, in this case http://127.0.0.1:5000



The page will wait for the response, so click on Forward till all the requests are sended. And check the history. It will come with other automatic request the firefox browser do.


To clean the output, just put a Filter on the address of interest and repeat the interception

The Result with filter



EOT

martes, 7 de julio de 2026

A Vision of Web Application Security 1

 A Vision of Web Application Security  1

To undersand the vulnerabilities of a Web Application, we need to think like an attacker do. In order to reach this, we will use a suite that works on webs applications that generates variants of the requests to simulate a normal traffic, and this suite is the burpsuite that works like a man in the middle in order to alter of modify the normal behaviour. it use a proxy configuration. The proxy configuration could be for a external server or a local server. for the local server configuration requires an extra configuration.

Normal Configuration before configure proxy




Step 1: Download and install Burpsuite

 

Once installed burpsuite, we use the proxy tab.

click on intercept on will show request that the system do to servers, some of them are automatic for telemetry and so on, and also request of our actions.


Step 2: configure the proxy setting to 127.0.0.1:8080


   Schema of Client, BurpSuite as Proxy and external Web Server

Step 3: Configure the proxy of the Firefox browser (App Proxy) and the CA Certificate

When open any website the browser responds with error



when Open any website respond with error...


Now go to http://burp to download cd CA Certificate


Go to the Administartion of certificates of the Firefox settings and add it.



 

From Now any web page can be opened in Firefox browser.

Step 4: On Tab Proxy click on intercept On , Do a Request to an external Site https://portswigger.net Click Open Browser, it will open the chrome browser,

...


...
Step 5: Now the intercept is active, the server is waiting for the request that is in brupsite proxy, to send to the server, press Forward or Forward All till all the frames finish to arrive to the server.



...
Step 6: Once finish the transaction, the history of traces are on Tab Proxy --> Tab Http History








miércoles, 27 de septiembre de 2023

Quarkus

 Quarkus

 
From Openshift docs
 
Tutorial Quarkus
aplicación CRUD OpenJDK11, Maven, Docker,MongoDB, extention panacheMongo, extension metics


Quarkus Extensions
-----------------------------------------------------------------------------------------------------------
Iniciativa Microprofile 3.2
 
   Open Tracing 1.3       OpenApi 1.1    RestClient 1.3                 Config 1.3
  
   Fault Tolerance 2.0    Metrics 2.2       JWT Autentication 1.1   Healt Check 2.1

   CDI 2.0                      JSON-P 1.1      JAX-RS 2.1                    JSON-B 1.0

-------------------------------------------------------------------------------------------------------------
  other
 
  Hibernate         Vert.x       Narayana      Camel     Apache Kafka    Agroal
  ORM

--------------------------------------------------------------------------------------------------------------
quarkus commands
mvn quarkus:create or code.quarkus.io
mvn compile quarkus:dev
mvn package -Pnative -Dquarkus.native.container-build=true
mvn quarkus:add-extension -Dextensions="quarkus-smallrye-health"
curl http;//localhost:8080/health/live
curl http://localhost:8080/health/ready
./mvnw quarkus:add-extension -Dextensions="quarkus-smallrye-metrics"
curl http://localhost:8080/metrics
curl --header "Accept:application/json" localhost:8080/metrics
./mvnw package -Pnative -Dquarkus.native.container-build=true
1:27:14 call docker image

Quarkus: de cero a Serverless en Kubernetes

Create fruit-service
$mvn io.quarkus:quarkus-maven-plugin:$QUARKUS_VERSION:create \
-DprojectGroupId="com.bext.atomic.fruit" \
-DprojectArtifactId="atomic-fruit-service" \
-DprojectVersion="1.0-SNAPSHOT" \
-DclassnName="FruitResource" \
-Dpath="fruit"
 
Run it
$mvn  clean quarkus:dev

Check it is running
>curl http://localhost:8080/fruit
Hello from RESTEasy Reactive
 
 Create the package for jvm
$./mvnw -DskipTests clean package

Once create the package which is in target folder
$java -jar ./target/atomic-fruit-service-1.0-SNAPSHOT-runner.jar
 
It says no main manifest attribute
$ java -jar atomic-fruit-service-1.0-SNAPSHOT.jar
no main manifest attribute, in atomic-fruit-service-1.0-SNAPSHOT.jar
 
time 16:00
 
To create a native run
$ ./mnvw -DskipTests clean package -Pnative
 
Once the native package is ready, it can be run directly
$ ./target/atomic-fruti-service-1.0-SNAPSHOT-runner.jar
 
 
./mvnw -DskipTests clean package -Pnative -Dquarkus,native,container-build=true -Dquarkus.native.container-runtime=podman

./mvnw quarkus:add-extension -Dextension="quarkus-resteasy-jsonb, quarkus-jdbc-postgresql, quarkus-hibernate-orm-panache"

usan h2 luego postgres y luego hacen portforward

curl http://localhost:8080/fruit/Summer
curl -vvv -d  '{"name": "Pineapple", "season":"Summer"}' -H "Content-Type: application/json" POST http://localhost:8080/fruit
./mvnw quarkus:add-extension -Dextensions="quarkus-smallrye-openapi"
$oc login
$export PROJECT_NAME="atomic-friut-k8s" 
$kubectl create ns ${PROJECT_NAME} 
$kubectl create deployment my-database --image=repository.access.redhat,com/rhscl/postgresql-10-rhel7:latest -n ${PROJECT_NAME}
$kubectl set env deployment/my-database POSTGRESQL_USER=luke POSTGRESQL_PASSWORD=secret POSTGRESQL_DATABASE=my_data -n ${PROJECT_NAME}
$kubectl expose deployment my-database --port=5432 --target-port=5432
$ oc get pod
o
$kubectl get pod
$ POD_NAME=$(kubectl get pod -o name | grep -v deploy)
$ kubectl port-forward ${POD_NAME} 5432
$ oc project atomic-fruit-k8s
$ oc get pod
 
application.properties
-----------------------------------
#log level settings
quarkus.log.category."com.redhat.atomic".level=DEBUG
 
#custom properties
hello.message = ${HELLO_MESSAGE:hello Meetup}
 
#Data Base
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database-generation=drop-and-create
quarkus,hibernate-orm.sql-load-script=import.sql
 
#%dev.quarkus.datasource.db-kind=h2
#%dev.quarkus.datasource.jdbc-url=jdbc:h2:mem:myDB
quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=jdbc:postgresql://my_database:5432/my_data 
quarkus.datasource.username=luke
quarkus.datasource.password=secret
-----------------------------------------------

./mvnw quarkus:add-extension -Dextension="kubernetes"
o la de openshift
./mvnw quarkus:add-extension -Dextension="openshift"
./mvnw quarkus:remove-extension -Dextension="container-image-docker"

application.properties continuation
-------------------------------------
#Kubernetes client
quarkus.kubernetes-client.trust-certs=true
quarkus.kubernetes-client.namespace=${PROJECT_NAME:atomic-fruit-k8s}
 
#Labels and annotations
quarkus.kubernetes.part-of=fruits-app
quarkus.kubernetes.name=atomic-friut-service
quarkus.kubernetes.labels.foo=bar
quarkus.kubernetes.annotations.foo=bar
quarkus.kubernetes-annotations-"app.quarkus/id"=42
 
#Environment variables
quarkus.kubernetes.env.vars.DB_USERNAME=luke
quarkus.kubernetes.env.vars.DB_PASSWORD=secret
 
#Configure container registry
quarkus.container-image.registry=quay.io
quarkus.container-image.group=luisarizmendi
quarkus.container-image.username=luisarizmendi
 -----------------------------------------
 
se crea archivo kubernetes/kubernetes.yml
kind: Ingress
metadata:
 name: atomic-friut-service
spec:
 rules:
  - host: fruits.app.cluster-2036.2036.example.opentlc.com
    http:
      paths:
       - path: /
          pathType: prefix
          backend:
            serviceName: atomic-friut-service
            servicePort: 8080
--------------------------------------------------
 
Comparte pantalla CArlos Vicens
github.com/cvicens/atomic-fruit-service/blob/master/quarkus-meetup.md
 
 
 Testing Quarkus App -Part 1    Daniel Oh

Testing in JVM mode
Testing in native mode
Injection of resources into tests
 
EXTENSION
<dependency>
   <grougid>io.quarkus</grougid>
   <artifactId>quarkus-junit5</artifactId>
   <version>${quarkus.version}</version>
   <scope>test</scope>
</dependency>
<dependency>
   <grougid>io.rest-assured</grougid>
   <artifactId>rest-assured</artifactId>
   <scope>test</scope>
</dependency>

PLUGIN
<artifactid>maven-surefire-plugin</artifactid>
  <version>${surefire-plugin.version}</version>
  <configuration>
      <systemPropertyVariables>

<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemPropertiesVariables>
</Configuration>
</plugin>
 
Mock Support 
- CDI alternatives
@Mock
@ApplicationScoped
public class MockExternalService extends ExternalService {
  @Override
  public String service(){
    return "mock";
  }
}
 
- Using QuarkusMock
@BeforeAll
public static void setup() {
   MockeableBean1 mock = Mockito.mock(MockeableBean1.class);
   Mockito.when(mock.greet("Stuart")).thenReturn("A mock for stuart");
   QuarkusMock.installMockForType(mock, MockeableBean1.class);
}
 
From example quarkus-rest-client-reactive
mvn verify
 
 Lets add an endpoint with param

example...

Test a CDI alternative with an example, create a service and inject with @Inject
  
example..

Change testp-port
application.properties
quarkus.http.test-port=8083

Debugging Quarkus App -Part II

Create a new endpoint for test debug

In STS4 with Quarkus marketplace runs fine.

 
 
 
Deploying Quarkus App to OpenShift - Part IV
 
Example 

Quarkus | Complete Quarkus Tutorial
1.- How to create a Quakus project with code.quarkus.io.
2.- How to create a Quakus project with apache maven.
3.- How to enable live Reload in Quarkus.
4.- How to add a new Quarkus extension inside a project.
5.- RESTful Web Service with Quarkus.
6.- Microprofile OpenApi with Quarkus.
7.- Swagger-ui with Quarkus.
8.- Microprofile Restclient with Quarkus.
9.- Enable CORS Filter in Quarkus.
10.- Quarkus Reactive SQL Clients with PostgresSQL.
11.- Microprofile Fault Tolerance with Quarkus Part 1.
12.- Microprofile Fault Tolerance with Quarkus Part 2.
13.- Microprofile Rest Client with TLS Authentication
14.- Hibernate ORM PanacheEntity with PostgresSQL.
15.- Hibernate ORM Panache Repository with PostgresSQL.
16.- Testing Quarkus application with RestAssured and H2 Database.
17.- MicroProfile Config with Quarkus.
18.- How to use YAML configuration with Quarkus.
19.- Testing Quarkus application with Junit5, Mockito and H2 Database.
20.- How to use configuration profiles in Quarkus.
21.- How to use logging in Quarkus.
22.- How to enable Json Logging in Quarkus.
23.- Undestanding application initialization and termination in Quarkus.
24.- Testing a Quarkus application with WireMock and Rest Assured.
25.- How to debug a Quarkus application with Intelij IDEA.
26.- MicroProfile Health with Quarkus.
27.- MicroProfile Metrics with Quarkus.
28.- How to package a Quarkus Application.
29.- How to compile a Quarkus Application in Native Mode.
30.- Docketize a Quarkus application with Dockerfiles.
31.- Dockerize Quarkus application with Apache Maven.
32.- Java bean mappings with MapStruct and Quarkus.
33.- How to use MapStruct to merge 2 Java Beans.
34.- Debug Quarkus application with Visual Studio Code.
35.- How to use Project Lombok inside Quarkus application.
36.- Setup Visual Studio Code with Java and Quarkus extensions.
37.- Create a Quarkus project using MongoDB.
38.- How to use Quarkus Command Mode.
39.- TDD approach with Continuous Testing in Quarkus.
40.- Containers Tutorials Part 1 - Containerize Java Application. Docker.
41.- #1 How to use Hibernate Validator extension with Quarkus.
42.- #2 How to use Hibernate Validator extension with Quarkus.
43.- How to use Flyway DB migration Tool sqlscript.
44 .- How to use Flyway DB migration Tool java-based migration.
45.- Authentication and Authorization using JWT and Roles-based access control.
46.- How to schedule periodic tasks with Quarkus.
47.- How to use to use the Test Security extension with Quarkus.
48.- How to use Dev Services in Quarkus 2.x.

Playlist Microprofile Specifications 
1.- Microprofile OpenAPI with Quarkus | Complete Tutorial | QUARKUS | Small Rye
2.- Microprofile RestClient with Quarkus | Complete Tutorial | QUARKUS | Resteasy | Java
3.- Microprofile Fault Tolerance with Quarkus Part I | Quarkus Tutorial | QUARKUS | SmallRye
4.- Microprofile Fault Tolerance with Quarkus Part 2 | Timeout | CircuitBreaker | Quarkus Tutorial
5.- MicroProfile Config with Quarkus | Quarkus Tutorial | QUARKUS | MicroProfile | Java
6.- MicroProfile Health with Quarkus | Quarkus Tutorial | QUARKUS | MicroProfile | Java | CloudNative
7.- MicroProfile Metrics with Quarkus | Quarkus Tutorial | QUARKUS | MicroProfile | Java | CloudNative
     @Counted
     @Timed
     @Metered
     @Gauge


6.- Microprofile OpenApi with Quarkus.
On the class
@Tag(name="Movie Resource" description="Movie REST APIs")
 On the method
@Operation(operationId="getMovies",
                     summary="Get Movies", 
                     description="Get all movies inside the list")
@APIResponse(responseCode="200",
                           description="Operation completed",
                           content=@Content(mediaType=MediaType.APPLICATION_JSON)
)
In Parameter method create 
public Response createMovie(
   @RequestBody( description="Movie to create",
                              required="true",
                              content= @Content(schema=@schema(implementation=Movie.class)
                            )
   Movie newMovie) { ...

On Movie.class
@Schema(name="Movie", description="Movie presentation")
public class Movie {...
    ...
    @Schema(required=true)
    private String Title;
 ...

Document a parameter on updateMovie with @Parameter annotation
public Response updateMovie(
   @Parameter(
        description="Movie id",
        required = "true"
   )
   @PathParameter("id") Long id;
   ....

To document the app use @OpenApiDefinition

@OpenApiDefinition(
     info= @info(title ="Movie APIs",
                           description="Movie Application",
                           version="1.0.0",
                            license=@license(
                                  name="MIT",
                                  url="http://localhost:8080"
                            )
                         ),
               tags = {
                  @Tag(name="movies", description="Movies app")}
)
public class MovieApplication extend Application{
}


                   

     
 
 
 
10.- Quarkus Reactive SQL Clients with PostgresSQL.
 
 Multi<Movie>
  Uni<Movie>
 
 PgPool client;
 
Multi<Movie> ,    
client.query("s ql instruction")
.flatMap(sql instruction)
.flatMap(sql instruction)
.await()
.indefinitely();
...onItem().transform(Movie::from);
 
 $docker run --name my_reactive_db -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=my_db -p 5432:5432 postgres:10.5

application.properties
quarkus.datasource.db-kind=postgres
quarkus.datasource.username=user
quarkus.datasource.password=password
quarkus.datasource.reactive.url=postgresql://localhost:5432/my_db

@GET
@PATH("{id}")
public Uni<Response> get(@PathParam("id") Long id) {
  return Movie.findById(client, id)
   .onItem()
   .transform(movie -> movie != null ? Response.ok(movie) : Response.status(Reponse.Status.NOT_FOUND))
  .onItem()
  .transform(Response.ResponseBuilder::build);
}
 
public static Uni<Long> save(PgPoll client, String title) {
  return client
   .prepareQuery("INSERT INTO movies (title) VALUE ($1) RETURNING id")
   .execute(Tuple.of(title))
    .onItem()
    .transform(m -> m.iterator().next().getLong("id");
}

@POST
public Uni<Response> create(Movie movie){
  return Movie.save(client, movie.getTitle())
    .onItem()
    .transform(id -> URI.create("/movies/" + id))
   .onItem()
   .transform(uri -> Response.created().build())
}

public statuc Uni<Boolean> delete(PgPool client, Long id) {
  return client
    .prepareQuery("DELETE FROM movies WHERE id = $1")
    .execute(Tuple.of(id))
    .onItem()
    .transform( m -> m.rowCount() == 1);
}

@DELETE
@Path("{id}")
public Uni<Response> delete(@PathParam("id") Long id){
  return Movie.delete(client, id)
     .onItem()
    .trasnform(deleted -> deleted ? Response.status(Response.Status.NO_CONTENT):              Response.status(Response.status.NOT_FOUND))
} 
  OR
@DELETE
@Path("{id}")
public Uni<Response> delete(@PathParam("id") Long id){
  return Movie.delete(client, id)
     .onItem()
    .trasnform(deleted -> deleted ? Response.Status.NO_CONTENT :  Response.status.NOT_FOUND)
    .onItem()
    .transform(status -> Response.status(status).build());
} 
 

11.- Microprofile Fault Tolerance with Quarkus Part 1.

 
Fault tolerance is about leveraging defferent strategies to guide the excecution and result of some logic. Retry Policies, Bulkheads, circuit breakers. fallbacks
- Timeout.
- retry.
- fallbacks.
- CircuitBreaker.
- BulkHead. isolate failures in part of the system while the rest part of the system can still function.  
 

12.- Microprofile Fault Tolerance with Quarkus Part 2.

Create a basic quarkus application RESTEasy JAX-RS and Jackson, clean unnecessary code.
 
 application.properties
quarkus.http.port=8081
quarkus.http.access-log.enabled=true
 
Another basic quarkus application RESTEasy JAX-RS, Jackson, REST Client, REST Client Jackson.
 
Test
$while true; do sleep 1; curl http://localhost:8080/message; echo -e '\n'; done
 
quarkus-service-message
MessageResource.java
 
 
-------------------------
quarkus-rest-client
MessageResource.java
@Path("/message")
public class MessageResource {
  @RestClient
  MessageClient client;
 
  @GET
  @Timeout(200)
  @CircuitBreaker( requestVolumeThreshold = 4,
                                failureRatio = 0.5,
                                delay = 4000,
                                successThreshold = 2)
  @Fallback(fallbackMethod = "fallbackMessage")
  public String message() {
     return client.get();
   }
 
  private String fallbackMessage() {
    return "Fallback Message";
  }
}
-------------------------
 
quarkus-service-message
INFO ....
"GET /message HTTP/1.1 200 34"
INFO ...  
"GET /message HTTP/1.1 200 34"
 
quarkus-rest-client
Fallback Message  
Fallback Message
Fallback Message
Fallback Message
 
When   
@CircuitBreaker( requestVolumeThreshold = 4,
                                failureRatio = 0.5,
                                delay = 8000,
                                successThreshold = 2)
 The quarkus-rest-client
Fallback Message  
Fallback Message
Fallback Message
Fallback Message
Fallback Message  
Fallback Message
Fallback Message
Fallback Message
 
Also
  @GET
  @Timeout(200)
  @Retry(maxRetries = 1)
  @Fallback(fallbackMethod = "fallbackMessage")
OR 
  @GET
  @Timeout(200)
  @Retry(maxRetries = 4)
  @Fallback(fallbackMethod = "fallbackMessage")

13.- Microprofile Rest Client with TLS Authentication

 
 quarkus.io/blog/quarkus-mutual-tls
Learn how to do mutual TLS in Quarkus apps. 

Create quarkus project simple without extensions for now
quarkus-restclient-tls
Now a new Module "quarkus-server" with extensions RESTEasy JAX-RS, RESTEasy Jackson
modify application.properties to disable port and enable another secure port
quarkus.http.ssl.certificate.key-store-file=META-INF/resources/server.keystore
quarkus.http.ssl.certificate.key-store-password=server_password
quarkus.http.port=0
quarkus.http.ssl.client-auth=required

quarkus.http.ssl.certificate.trust-store-file=META-INF/resources/client.truststore
quarkus.http.ssl.certificate.trust-store-password=client_password
quarkus.http.ssl-port=8443

create keystore
quarkus-server/src/main/resources/META-INF.resources/generate_server_keystore.sh
keytool -genkeypair \
          -storepass server_password \
          -keyalg RSA \
    -keysize 2048 \
    -dname "CN=server" \
   -alias server \
  -ext "SAN:c=DNS:localhost, IP:127.0.0.1" \
  -keystore server.keystore
 
This shell script creates .../META-INF.resources/server.keystore

14.- Hibernate ORM PanacheEntity with PostgresSQL.

Create Project quarkus-hibernate-orm-panache-entity
 web->RESTEasy JAX-RS,RESTEasy Jackson
 
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAll() {
  List<Movie> movies = Movie.listALL();
  return Response.ok(movies).build();
}

@GET
@Path("{id]")
@Produces(MediaType.APPLICATION_JSON)
public Response getById(@PathParam("id") Long id) {
  return Movie.findByIdOptional(id)
    .map(movie -> Response.ok(movie).build())
    .orElse(Response.status(Response.Status.NOT_FOUND).build());
}

@GET
@Path("country/{contry}"
@Produces(MediaType.APPLICATION_JSON)
public Response getByCountry(@PathParam("country") String country) {
  List<Movie> movies = Movie.List("SELECT m FROM MOvie m WHERE m.country = ?1 ORDER BY id " + "DESC", country);
  return Reponse.ok(movies).build();
}

@GET
@Path("title/{title}"
@Produces(MediaType.APPLICATION_JSON)
public Response getByTitle(@PathParam("title") String title) {
  return Movie.find("title", title)
      .singleResultOptional()
      .map(movie -> Response.ok(movie).build())
      .orElse(Response.status(Response.Status.NOT_FOUND).build());
}
 
@POST
@Transactional
@Produces(MEdiaType.APPLICATON_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response create(Movie movie) {
  Movie.persist(movie);
  if (movie.isPersistent()){
     return Response.created(URI.create("/movies" +      movie.id)).build();
  }
  return Response.status(Response.Status.BAD_REQUEST).build();
} 

@DELETE
@Transactional
@Path("id")
@Produces(MEdiaType.APPLICATON_JSON)
public REsponse deleteById(@PathPAram("id") Long id) {
  boolean deleted = Movie.delete(id);
  if (deleted) {
    return Response.noContent().build();
  }
  return Response.status(Response.Status.BAD_REQUEST).build();
}


Docker

$docker run --name my_db_movie -e POSTGRES_USER=username -e POSTGRES_PASSWORD=password -e POSTGRES_DB=my_db_movie -p 5432:5432 postgres:10.5
 
aplication.properteis
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/my_db_movie
...
quarkus.hibernate-orm.database.generation=drop-and-create

add extension quarkus-hibernate-orm-panache
add extension quarkus-jdbc-postgresql

Test with Postman de movie crud

 
  

15.- Hibernate ORM Panache Repository with PostgresSQL.

Create Project quarkus-hibernate-orm-panache-repository
 web->RESTEasy JAX-RS,RESTEasy Jackson
 data->Hibenate ORM with Panache, JDBC Driver PostgresSQL,Agroal - Database connection pool


blabla

16.- Testing Quarkus application with RestAssured and H2 Database.

 
bla bla


Deploying Quarkus App to OpenShift - Part IV
Daniel Oh
 
src/main/resources/application.properties
...
quarkus.kubernetes-client.trust-certs=true
quarkus.container-image.build=true
quarkus.kubernetes.deploy=true
quarkus.kubernetes.deployment-target=openshift
quarkus.openshift.expose=true
quarkus.openshift.labels.app.openshift.io/runtime=quarkus
quarkus.s2i.base-jvm-image=registry.access.redhat.com/ubi8/openjdk-11 

add openshift extension

$ ./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-openshift"