Enhancement
As a developer I would like to have Spring Boot provide a Service Connection for a local Kubernetes Cluster, similarly to the integration with Docker Compose or Testcontainers, for developing apps that have dependencies running in local Kubernetes.
Context / Motivation
Spring Boot 3.1 introduces Service Connections supporting Testcontainers and docker-compose.
The projects in our companies used to have docker-compose files for local setup. In production Kubernetes is used. To achieve a higher dev-prod parity and reduce the effort to maintain the deployment manifests, we switched all docker-compose files to kubernetes declarations.
It would be nice to have Spring Boot be able to deploy the required workload to k8s and autoconfigure the application to use it upon startup and to undeploy the workload upon shutdown similarly to docker-compose and testcontainers.
Comment From: scottfrederick
@clboettcher How are the connection details and credentials for the services running in Kubernetes exposed to pods in your situation? We'd need to know more about that before we could decide if this is a good fit for Service Connections.
One way that service connection details can be exposed on Kubernetes is through service bindings. This is already well-supported in Spring Boot applications using the Spring Cloud Bindings library. Spring Cloud Bindings does not yet use the Service Connections abstraction from Spring Boot, but it might in the future. Does this meet your needs?
Comment From: clboettcher
@scottfrederick I should have added a disclaimer, that the projects I was referring to are based on JEE/Quarkus. Therefore I cannot provide the details you are asking for as I am not familiar with those terms.
However, I still think the enhancement is valid, because I assume, teams using Spring Boot also work with k8s locally.
I just heard a talk from @mhalbritter about this stuff and I found it very useful, that Spring Boot is able to deploy the required workload to docker-compose/testcontainers and autoconfigure the application to use it upon startup and to undeploy the workload upon shutdown without using external tools. This is what I would love to see supported for dependencies running in k8s.
Comment From: philwebb
I think this issue is probably a duplicate of #21322
Comment From: scottfrederick
My first comment was responding to the idea about consuming services on Kubernetes, which I think is what #21322 intends to address also.
The idea of automatically deploying and undeploying workloads to Kubernetes in a development workflow is a separate concern, and it's not clear to me yet how we would accomplish this in a general-purpose way or if it is something Spring Boot should attempt to do. Docker Compose (with a CLI and conventions on compose.yaml file names) and Testcontainers (with a Java API) have small interfaces that specifically address starting and stopping containers. Kubernetes interfaces are much more broad so we might have to come up with our own conventions to simplify things for users. And the application would have to know how to find the Kubernetes that the service workloads are running on.
If this is an idea worth exploring, I wonder if it would be better suited for Spring Cloud Kubernetes than for Spring Boot.
Comment From: wilkinsona
If this is an idea worth exploring, I wonder if it would be better suited for Spring Cloud Kubernetes than for Spring Boot.
+1. Spring Cloud Kubernetes feels like a better fit to me for that part of things.
Comment From: philwebb
+1, I think this is too Kubernetes specific for us to include in Spring Boot. @clboettcher, feel free to raise an issue with Spring Cloud Kubernetes to get feedback from that team.