Difficulty: Beginner
Estimated Time: 15 minutes

Spring Boot to Kubernetes

The scenario walks through a series of steps that go from a blank slate of no code to running a Spring Boot application on Kubernetes. Starting with a blank Kubernetes cluster and an empty source code directory these steps will:

  1. Generate a Spring Boot skeleton project for a demo application
  2. Add some basic REST endpoints to the code
  3. Define a multi-stage Dockerfile
  4. Build the jar and the container
  5. Push the container to a local, private registry
  6. Send a declaration to Kubernetes to start the demo application
  7. Run the application

You will learn how to:

  • write a getting started Spring Boot application
  • run a Gradle (or Maven) build when the container is built
  • push a container to a private registry on Kubernetes
  • instruct Kubernetes to start and application
  • access an application service running on Kubernetes

A good followup to this scenario is Distilling Java Containers.

Conclusion

You know know how to create, build, deploy and run a Spring Boot application on Kubernetes.

It can get more complex than this with different dependencies, Java versions and base container flavors. However this is a great starting point.

If you are concerned about the image size, the startup time or configuring the memory and CPU head over to the scenario Distilled JRE Apps in Containers.

Lessons Learned

With these steps you have learned how to:

  • ✔ write a getting started Spring Boot application
  • ✔ run a Gradle (or Maven) build when the container is built
  • ✔ push a container to a private registry on Kubernetes
  • ✔ instruct Kubernetes to start and application
  • ✔ access an application service running on Kubernetes

References


No Fluff Just Stuff

For a deeper understanding of these topics and more join me, Jonathan Johnson, for a transcendent experience on the No Fluff Just Stuff Software Symposium Tour.

Spring Boot to Kubernetes

Step 1 of 8

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can administer your cluster with the kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.

token.sh

Terminal
Kubernetes Dashboard
Hello App