This blog will show how a simple Java application can talk to a database using service discovery in Kubernetes.
Service Discovery with Java and Database application in DC/OS explains why service discovery is an important aspect for a multi-container application. That blog also explained how this can be done for DC/OS.
Let’s see how this can be accomplished in Kubernetes with a single instance of application server and database server. This blog will use WildFly for application server and Couchbase for database.
This blog will use the following main steps:
- Start Kubernetes one-node cluster
- Kubernetes application definition
- Deploy the application
- Access the application
Start Kubernetes Cluster
Minikube is the easiest way to start a one-node Kubernetes cluster in a VM on your laptop. The binary needs to be downloaded first and then installed.
Complete installation instructions are available at github.com/kubernetes/minikube.