Page tree
Skip to end of metadata
Go to start of metadata

This page details a migration of an AWS elasticbeanstalk deployment of a Java microservice with an RDS backend database to docker, kubernetes and helm.

Spring boot based reference architecture - Reference Architecture

Spring boot war deployed to tomcat - Java Spring JPA Microservice on Kubernetes or EKS or ECS or Docker or Beanstalk or EC2 Tomcat Spring Boot

Spring boot jar running the spring embedded tomcat container - Spring Boot Microservice

Infrastructure

Docker

Containerization of Maven Built Artifacts

https://blogs.oracle.com/javamagazine/containerizing-apps-with-jlink

DockerFile using tomcat image

FROM tomcat:8.0.48-jre8
COPY target/biometric.web-*-SNAPSHOT.war /usr/local/tomcat/webapps/biometric.web.war

DockerFile using alpine image


Build/Tag/Deploy Docker Image

see https://hub.docker.com/r/obrienlabs/biometric-web and https://github.com/obrienlabs/biometric under  BIOMETRIC-10 - Getting issue details... STATUS


obrienlabs:biometric.web.docker michaelobrien$ ./build.sh 
Sending build context to Docker daemon  50.96MB
Step 1/2 : FROM tomcat:8.0.48-jre8
8.0.48-jre8: Pulling from library/tomcat
723254a2c089: Pull complete 
a23d5c1d9825: Pull complete 
Digest: sha256:b2cd0873b73036b3442c5794a6f79d554a4df26d95a40f5683383673a98f3330
Status: Downloaded newer image for tomcat:8.0.48-jre8
 ---> e072422ca96f
Step 2/2 : COPY target/biometric.web-*-SNAPSHOT.war /usr/local/tomcat/webapps/biometric.web.war
 ---> 5cd1152a967b
Successfully built 5cd1152a967b
Successfully tagged obrienlabs/biometric-web:latest
obrienlabs/biometric-web             latest              5cd1152a967b        1 second ago        608MB
Authenticating with existing credentials...
Login Succeeded
The push refers to repository [docker.io/obrienlabs/biometric-web]
2d64f287a896: Pushed 
7a5faefa0b46: Layer already exists 
d1a0f91a1ad8: Layer already exists 
c4d99fd86e94: Layer already exists 
04178c827c65: Layer already exists 
c571db474d75: Layer already exists 
93742a1ae069: Layer already exists 
7ffe9646653b: Layer already exists 
6ef532e39c1e: Layer already exists 
a4d7b0ac0438: Layer already exists 
06f4de5fefea: Layer already exists 
851f3e348c69: Layer already exists 
e27a10675c56: Layer already exists 
0.0.1: digest: sha256:dac09eb8c16fe9d5fb0080479e183acddbd178f77ab60d24fe7072aef0d7d073 size: 3048

Run Docker Image locally

obrienlabs:biometric.web.docker michaelobrien$ docker run /
  --name biometric_web \
  -d \
  -p 8888:8080 \
  -v ~/Dropbox/env/mbp4/biometric/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml \ 
  obrienlabs/biometric-web 
f0f35ace3cacd4dbfd1be709975afc5ff28c22dfe19f014d898db3ce26b35d81

obrienlabs:biometric.web.docker michaelobrien$ docker ps -a | grep biometric
f0f35ace3cac        obrienlabs/biometric-web   "catalina.sh run"        37 seconds ago      Up 36 seconds       0.0.0.0:8888->8080/tcp   biometric_web
# check credentials
obrienlabs:biometric.web.docker michaelobrien$ docker exec -it biometric_web /bin/bash
root@f0f35ace3cac:/usr/local/tomcat# cat conf/tomcat-users.xml
<tomcat-users>
  <role rolename="admin-gui"/>
  <user username="tomcat" password="tomcat" roles="manager-gui"/>
</tomcat-users>

Login

http://127.0.0.1:8888/manager/html

Check logs

obrienlabs:biometric.web.docker michaelobrien$ docker exec -it biometric_web /bin/bash
root@f0f35ace3cac:/usr/local/tomcat/logs# cat localhost.2019-09-04.log 

fix
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'os.environment.configuration.dir' in string value "file://${os.environment.configuration.dir}/${os.environment.ecosystem}"


obrienlabs:biometric.web.docker michaelobrien$ docker stop biometric_web
biometric_web
obrienlabs:biometric.web.docker michaelobrien$ docker rm biometric_web
biometric_web
obrienlabs:biometric.web.docker michaelobrien$ docker run --name biometric_web -d -p 8888:8080 -v ~/Dropbox/env/mbp4/biometric/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml -v ~/Dropbox/env/mbp4/biometric/setenv.sh:/usr/local/tomcat/bin/setenv.sh -e os.environment.configuration.dir=/ -e os.environment.db.biometric.schema=biometric -e os.environment.db.url=jdbc... -e os.environment.db.username=yyyy -e os.environment.db.password=yyyy -e os.environment.discriminator=biometric -e os.environment.ecosystem=prod obrienlabs/biometric-web 
af2c86207d63a02707872b86c6e5d624d7f4cf3a1c05154008986f2aab8a53f2

obrienlabs:biometric.web.docker michaelobrien$ docker exec -it biometric_web /bin/bash
root@af2c86207d63:/usr/local/tomcat# cat logs/localhost.2019-09-04.log 
04-Sep-2019 20:46:01.509 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
04-Sep-2019 20:46:01.664 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
04-Sep-2019 20:46:09.729 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
04-Sep-2019 20:46:09.729 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()

Check website

http://127.0.0.1:8888/biometric.web/

r:5671,s:4271172,hr1:null,hr2:null,45.344003,-75.940494,54

Deployment to EC2

Deployment to ECS

Deployment to EKS

Deployment to Kubernetes

Deployment to Kubernetes on Docker Desktop

Deployment to Kubernetes on RKE

RDS for backend MySQL Database



  • No labels

1 Comment

  1. Figured out the issue of why the RDS tunnel is not connecting from inside docker - forgot that 127.0.0.1 inside docker means "this" container itself - not the host machine where the tunnel is running. so application.properties will need to be "host.docker.internal" instead of 127.0.0.1 when debugging appmgr locallythis works now
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(
    "jdbc:mysql://host.docker.internal:3406/biometric?useSSL=" + useSSL, username, password);
    obrienlabs@172.31.94.184