No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
deployment
liberty-postgres
liberty
src/main
.gitignore
Dockerfile
README.adoc
docker-run-config-example.sh
docker-run-database.sh
docker-run-local.sh
pom.xml

README.adoc

Build

In order to build the example Docker image, build the openliberty-postgres image, first:

$> cd liberty-postgres/
$> docker build -t openliberty-postgres:1 .

Then you can build the actual project:

$> mvn clean package
$> docker build -t config-example:1 .

Run

In order to run the application in a Docker container, it needs the database credentials at runtime. We need access to them locally, without storing them under VCS. We can create the file via command line:

$> cat <<< EOM > /tmp/bootstrap.properties
config-example.db.username=postgres
config-example.db.password=postgres
EOM

In order to run the Docker containers locally, execute ./docker-run-local.sh. As a prerequisite, you need to create a Docker network first:
docker network create --subnet=192.168.42.0/24 dkrnet

Kubernetes deployment

The Kubernetes deployments expects a secret that contains the database credentials. In order to avoid storing the credentials under VCS, we create the secret via command line:

$> kubectl create secret generic database-credentials --from-file=/tmp/bootstrap.properties

Once the secret database-credentials has been created, we can deploy our Kubernetes application via the definition under deployment/config-example.yaml. Please be aware that a Postgres database is expected to be resolvable under the hostname config-example-db in the default Kubernetes namespace. You can either deploy a Postgres database in the same namespace, or use a headless service to point to an external address.