Chapter 2. Deploying a Java Application to Kubernetes

This chapter will explain how to start a Kubernetes cluster. It will also demonstrate CRUD (create, read, update, and delete) operations for different resources on this cluster. Service discovery and scaling the number of containers in a service will be discussed as well. Finally, you’ll learn how to deploy a simple Java application to Kubernetes using Maven.

All resource files in this chapter are available in the GitHub repo for this book.

Managing Kubernetes Cluster

You can create a Kubernetes cluster on your laptop, virtual machine (VM), cloud provider, or a rack of bare-metal servers. For development purposes, it’s easiest to start with a one-node cluster using Minikube. For production purposes, hosted solutions or cloud-based solutions provide the scalability and higher availability you’ll need. A complete list of solutions to create Kubernetes clusters is available at the Kubernetes website.

This section will explain how to create and shut down a development Kubernetes cluster using Minikube. The deployment of such an application typically happens on a cloud platform such as Amazon Web Services (AWS). A common way to start a single-master cluster and a highly available cluster using Kops on AWS is also explained.

Development Cluster Using Minikube

Minikube runs a single-node Kubernetes cluster inside a VM on your laptop. This allows you to try out Kubernetes on your local machine easily. Minikube packages and configures ...

Get Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.