Oct 26 2020

Spring Boot + Kubernetes = Love (or something like that)

Category: MiscellaneousIuliana @ 22:31

In the previous entry I had a Spring Boot application running in a Docker container. And that is good. But an application designed to be used my a lot of users should be scalable. Well… not the app per-se, but the setup managing it. So, I have a container with an application running. What if more users access it than the poor container with its limited resources can handle? Well, in this case, I need another container with the same application installed and a component called a load balancer that will direct traffic as needed. This is where Kubernetes comes in handy.

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications. This means, now that I have an image of my containerized application, I can use Kubernetes to deploy it on more than one container and I can use it to manage my containers. I can decide the resources assigned to a container and I can tell Kubernetes how many containers I want for crowded and lighter situations. Kubernetes can do a lot for me, but I will focus here on something called Horizontal Pod Autoscaler – you can configure one of these to manage a number of containers. As the name of this components says it quite clearly, I can configure it to automatically decide the number of container with my application that need to be up and running based on a specific criterion. And because it is the easiest for me to do, my criteria will be the CPU load percentage. (instead of users requests)
Continue reading “Spring Boot + Kubernetes = Love (or something like that)”

Tags: , , , , ,

Oct 17 2020

Spring Boot + Docker = Love (or something like that)

Category: TechnicalIuliana @ 16:30

Feel free to open a beer and celebrate this technical entry. I don’t do this often, because I prefer to dedicate my spare time to projects that soothe my soul, like playing the piano. But, I want to improve the structure and capabilities of the project for my future books, so here I am combining my expertise on Spring with my expertise in cloud technologies in a (hopefully) graceful way.

In this entry I am going to show you how to create a simple Spring Boot Web application and deploy it to a Docker container. I will walk you thorugh my process, and assume I am starting with a black slate and install various tools as I need them.

Initial prerequisites:

  • JDK 15 (I usually set the JAVA_HOME environment variable and add $JAVA_HOME/bin to the system path)
  • Gradle 6.5.1(I set the GRADLE_HOME environment variable and add $GRADLE_HOME/bin to the system path). I know Gradle Wrapper exists, but I like having Gradle on my system and managing it with SDKMAN. I am stuck to the 6.5.1 version, since the Palantir plugin does not want to work with more recent versions.
  • IntelliJ IDEA IDE, the best Java editor I’ve worked with so far.

Continue reading “Spring Boot + Docker = Love (or something like that)”

Tags: , , ,