springboot-Deploy dockerized springboot app container into kubernetes example
This post would demo how to deploy dockerized springboot applications into kubernetes, and in the same time, I would demo how to add externalised configration files to the dockerized springboot application.
3. The tutorial
3.1 Add Dockerfile to your Springboot app
3.2 Add Config Map from your application.propertes file
Use this command to create a Config Map in your kubernetes cluster:
3.3 Create a deployment in your kubernetes cluster
In the upper yaml file, I defined a ConfigMap Volume named vol1, and mount it at the /opt/myserver/conf, which is used by the Dockerfile’s “–spring.config.location”.
View the k8s status:
Then everything is done.
Deploy springboot into k8s is easy, but if want to externalize the configuration files , you should use ConfigMap instead of adding the config file into the container, which is tightly coupled with the appcodes, ConfigMap can be changed on the fly, without interfering the application development.