Difficulty: Beginner
Estimated Time: 20 minutes

Spring Boot is a great way to write an application in Java. This scenario shows you how to create a Spring Boot application and run it in Kubernetes with as little fuss and bother as possible. And there's no YAML. To do this we need to do three things:

  1. Create a Spring Boot application
  2. Containerize it, and push the container to a registry
  3. Deploy it to Kubernetes

You will need a few minutes of time. If you have credentials for a public docker registry, like Dockerhub or Google Container Registry, that will help, but it won't stop you from completing the scenario.

We don't cover all the features of Spring and Spring Boot. For that you could go to the Spring guides or Spring project homepages.

We also don't cover all the options available for building containers. There is a Spring Boot topical guide covering some of those options in more detail.

When it comes to deploying the application to Kubernetes, there are far too many options to cover them all in one tutorial. We can look at one or two, but the emphasis will be on getting something working as quickly as possible, not on how to deploy to a production cluster.

Source code for this guide is in Github. It is deployed in Katacoda where you can run the code interactively in your browser.

Well done! You built an app, containerized it and pushed it to Kubernetes. Here are the links again to the Spring guides and Spring project homepages. And the Spring Boot Docker covering some more of the containerization options.

Install Kubernetes

Step 1 of 2

Install and Run Kubernetes

Before you can start, you need to install and start the Kubernetes cluster.

Install Kubectl

Kubectl is the command line for Kubernetes. You can install it from Google storage:

curl -Lo /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.15.3/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

Create a Cluster with Kind

Kind is a tool for running Kubernetes in docker. It works well for integration testing, or for simple development-time use cases, where resources are constrained. You can install it from github:

curl -Lo /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-linux-amd64 && chmod +x /usr/local/bin/kind

and run it to create a (single node) Kubernetes cluster:

kind create cluster

Then set up the credentials to connect to to the cluster:

mkdir -p ~/.kube && kind get kubeconfig > ~/.kube/config

Check that it works:

kubectl get all

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/kubernetes   ClusterIP   10.43.0.1       <none>        443/TCP    2d18h

Now we can deploy our Spring Boot application.