Kubernetes Controller Pattern Example with Java and MySQL

A controller written in Java that creates MySQL databases in a Kubernetes cluster

This post is a continuation of Kubernetes with Java - Handling Events which showed us how to subscribe to API events for a given type of Kubernetes resource and deal with them in near real-time. In this post, we will learn how to use that capability along side other client machinery components to write a Kubernetes controller. What are we trying to do For this post, our goal is to make it easier to create multiple MySQL database instances in a Kubernetes cluster. [Read More]

10x Faster Spring Boot Startup Times

Spring Native Startup Performance

Applications based on spring-boot are not known for extremely fast startup times and low memory usage. Usually spring-boot application are meant for long running backend processes and we have learned to live with the startup time and higher memory usage. This is because leveraging spring-boot solves so many other problems for the developer and speeds up the overall development process. In other words, we are OK with more developer productivity at the cost of higher resource usage at runtime specially at application startup. [Read More]

Kubernetes with Java - Handling Events

Handling Kubernetes API events in Java

This post is a continuation of Kubernetes with Java - Asynchronous APIs which showed us how to interact with the Kubernetes API to list deployment resources on demand. In this post, we will learn how to handle Kubernetes API events in near real-time. An example use case for this capability might be to send a notification to a slack channel whenever an app deployment is started or when it finishes and becomes ready to be consumed. [Read More]

Kubernetes with Java - Creating Images

Bundling your Java apps into OCI images to run under Kubernetes

Building production quality images for Java apps To run a spring-boot app on k8s, you need to create a container image. The images need to be in the Open Container Image format. In this article, we will review how to create OCI images two different ways: Using a Dockerfile Using Cloud Native Buildpacks Note: The Open Container Image (OCI) format antecedent of the Docker image format as a standard specification. [Read More]

Kubernetes with Java - Running in the Cluster

Using Kubernetes API through a Java app from inside the Kubernetes cluster with RBAC

What are we going to do? This post builds on top of Kubernetes with Java - Introduction and Kubernetes with Java - Asynchronous APIs posts which showed us how to interact with the Kubernetes API to list deployment resources and provide an API of our own to list teams and apps belonging to those teams running in the cluster. In this post, we will Configure a spring-boot app to be able to access the Kubernetes API when running inside a Kubernetes cluster Learn how to package up a spring-boot app into an OCI image (aka Docker image) Configure RBAC with Role, RoleBinding, and ServiceAccount so our spring-boot app has the ability to run with only the Kubernetes APIs that we think it should have access to and nothing more Create Deployment and Service resources to deploy our spring-boot app and expose its API within the cluster Prerequisites Access to source code for the project - https://github. [Read More]

Kubernetes with Java - Asynchronous APIs

Choosing between synchronous and asynchronous Kubernetes API in Java

What are we going to do? This post builds on top of Kubernetes with Java - Introduction which relied on synchronous Kubernetes API to get information for apps runnings in Kubernetes cluster. In this post, we will Learn when to use synchronous and when to use asynchronous Kubernetes API mechanisms Learn how to use asynchronous Kubernetes API to exrtact deployments metadata How to use spring-boot profiles to conditionally enable functionality Synchronous vs asynchronous APIs Kubernetes API provides two mechanisms to consume information for the clients. [Read More]

Kubernetes with Java - Introduction

Getting started with the Kubernetes API client libraries for Java

What are we going to do? Learn how to initialize the k8s api client in a java spring-boot application Extract metadata from deployments in a namespace and transform that metadata into new views Prepare you for more sophisticated problem solving using the k8s API in future articles Motivation You have a few dozen different applications (as Kubernetes deployment resources) running in your cluster All of those applications use labels to designate the name of the team that manages that application, and the application name You want to provide APIs that: Lists all teams that have applications running in the cluster Lists all apps that belong to a team Scenario Assumption: you have minikube locally and you don’t already have a namespace called dev. [Read More]