Skip to content

sdaschner/openliberty-config-example

 
 

Repository files navigation

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.

Run Prometheus on Kubernetes

In order to run the Prometheus Operator example on Kubernetes, first install Prometheus Operator on your cluster. You can either apply the file in the deployment/prometheus-operator directory, or use a Helm chart.

In order to make use of Prometheus Operator, simply apply all files in the deployment/ directory to your cluster, after you have created the database-credentials secret.

kubectl apply -f deployment/

This will create the services and deployments for the example-config application, example-config-db database, as well as Prometheus Operator and Grafana instances.

Also have a look at this blog post on how to monitor applications using Prometheus Operator on Kubernetes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors