If you ever ran a serious production database (is there any other kind, really? 🤔 ), you are most likely using some sort of database migration tool. Tools like Flyway, Liquibase or Knex for JS are pretty good at that and haven’t caused much trouble in our lives until we started treating our apps as cattle and run them in K8s, replicated, rescheduled every now and then, without us even knowing. They scale up and down automatically, sometimes even in the middle of the night while we sleep soundly in our beds. Then something interesting starts to happen….
Kubernetes Health Probes With Spring Boot 101
Kubernetes health probes have just become first class citizens in Spring Boot! Just before the release of Spring Boot 2.3, this article appeared on the Spring blog. These are awesome news because now you can leverage the framework and remove all that custom logic for liveness and readiness checks you have written in the past. In this post, let’s see how you can setup this feature in your application.
Create a demo application
For this tutorial, create a simple spring boot web application that fetches some products. We will create a Product domain entity:
Inspect JVM running in Kubernetes with VisualVM
Often times, you will run into obscure errors that require you to take a peek under the JVM hood, which in itself can be a daunting task. In this tutorial, we will take a look on how to troubleshoot a running application in a Kubernetes cluster with VisualVM as well as how to inspect Heap Dumps and how to pass them from the container to our machine.
For this example, we have a Hello Spring Boot Application (the code can be found here) that saves a timestamp of each request in memory (in order to provide us some interesting data for us to analyze later on). We will be working hands on with VisualVM so make sure to download it and start it up, it is very straightforward and here is the link. One could also use JConsole for such a task but let’s leave that for some other time.