Camel K demonstration on how to create REST API integrations and connect to databases.
Parameter | Example Value | Definition |
---|---|---|
token |
sha256~vFanQbthlPKfsaldJT3bdLXIyEkd7ypO_XPygY1DNtQ |
access token for a user with cluster-admin privileges |
server |
OpenShift cluster API URL |
You will need an user with permission to create a project and install operators on cluster level.
Export the user’s token
and the server
API address as environment variables, then run the following command under the ansible
folder:
cd demos_camel_k/ansible/ ansible-playbook -e token=${token} -e server=${server} playbook.yml
First you need to prepare the environment by creating the database used by the application:
# make sure you're logged in the right cluster oc login oc new-app --name postgresqldb -e POSTGRESQL_USER=redhat -e POSTGRESQL_PASSWORD=redhat -e POSTGRESQL_DATABASE=camelk quay.io/gcamposo/postgresql-camelk:latest -n demo-camelk-api
now you can create the integrations following the instructions:
cd demos_camel_k/camel_k oc create cm camel-k-api --from-file=openapi.yml kamel run API.java kamel run Client.java
oc project demo-camelk-api kamel run API.yaml --dependency=mvn:io.quarkus:quarkus-jdbc-postgresql --dependency=camel:jdbc --dependency=camel:jslt --trait=route.enabled=true --trait=logging.json=false --trait=prometheus.enabled=true --open-api=file:openapi.yml --build-property=quarkus.datasource.camel.db-kind=postgresql --resource=file:spec.json --property=file:db.properties