Example application for spring-boot and postgresql
- Java 91.1%
- Shell 8.9%
| .vscode | ||
| kustomize | ||
| src/main | ||
| target | ||
| mvnw | ||
| mvnw.cmd | ||
| pom.xml | ||
| Readme.md | ||
| setenv.sh | ||
Spring Boot Accessing relational DB
This is a customized version of Accessing data with MySQL
- ported to work with PostgreSQL (user is reserved, so we use my_user in pg)
- make an OpenShift / Kubernetes Deployment
local start
- Start local PostgreSQL with:
- DB: db_example
- User: springuser
- PW: ThePassword
- Source the config
. ./setenv.sh - make clean
mvn clean - run
mvn spring-boot:run
You can use the REST Service in another Terminal Session with:
curl http://localhost:8080/demo/allto query your tablecurl http://localhost:8080/demo/add -d name="My Famous new user" -d email="noone@no.address.com"to add records
deploy on OpenShift / OKD
- go in your namespace:
oc project mytestproject - Build the container: `kustomize build kustomize/openshift-build/ | oc apply -f -``
- for the first time the build ist started automatic. After this you can restart the builds and show the output on commandline with
oc start-build accessingdata -F - make a new instance dir with the content of
./kustomize/instancetemplate/(for example./kustomize/my_instance/) - edit the
kustomization.yamlinmy_instance(Look for namePrefix, storageclasses and sizes) - roll out using
kustomize build my_instance | oc apply -f -
Test your work:
-
find the route of your service with
oc get route -
test it:
export MYSVC=pp002-accessingdata-dev-mytestproject.apps.mysupercluster.net curl https://$MYSVC/demo/all curl https://$MYSVC/demo/add -d name="My Famous Name" -d email="this@one.does.not.exists" curl https://$MYSVC/demo/all