Kustomize: A Tool for Kubernetes Configuration Management

Kubernetes (k8s) is an increasingly popular container orchestration platform. With that popularity has grown an ecosystem of tools and frameworks. One such tool is Kustomize.

K8s desired states are declaratively described in resource description files such as deployment, services, configmaps, secrets, etc. As we vary the environments from dev to QA to prod these configurations to change. The database may change from an embedded H2 in dev to a MariaDB in QA to Oracle in prod, the amount of allocated memory for a container may change, secrets of user rid and password for the database may also change. Managing all these varying YAML files of deployment, services, etc. per environment can be quite a chore. Configuration management tools maintain consistency across these environments.

Kubernetes for Java Developers

Microservices is a style of architecture consisting of a small, individual application component with a single responsibility, with a high degree of autonomy in terms of deployment and scalability. These components communicate via a lightweight protocol like REST over HTTP. In consequence, development teams are small (the two-pizza rule), focused on a microservice. In practice the team owns the entire lifecycle from development to deployment — if you built it, you run it. This creates a problem. After all, dev teams’ core competency is usually Maven, a microservices framework, say, Spring Boot, test frameworks like JUnit, and so on. But if we look at the steps involved in deploying a microservice:

  • Package the application in a container like Docker. This involves writing a Dockerfile.
  • Deploy the container to an orchestrator like Kubernetes. This involves writing several resources; description files for services, deployment, etc.

To use a term familiar to developers, this is an ‘impedance mismatch.’ To solve this problem, we need a class of tools that speak the language of developers and make the entire deployment steps transparent to them. The most famous of these is Jib, which we dealt with in a previous paper, which builds optimized Docker and OCI images for your Java applications and is available as a Maven plugin. There are other tools in this category like Dekorate which allows us to generate Kubernetes manifests using just Maven and Java annotations. The latest and comprehensive entry in this category is JKube from RedHat which our subject de jour.

From Modules to Microservices via a Service Mesh

The title says it all, but details are always welcome. But first some definitions. According to the classic article by Martin Fowler:

“The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable.”

Two Ways to Dockerize Spring Boot Applications

Microservices are often built with the Spring Boot framework and deployed with Docker. This paper looks at two common options for Dockerizing Spring Boot applications. Throughout we will use a simple REST application as a running example.

We will use Spring Tool Suite to build the application, though neither the IDE nor the application matter all that much, as long as we have the pom file. We will assume that the reader has minimal knowledge of Docker, though as we shall see one of the options we will discuss, requires no knowledge of Docker. Here then is the REST controller: