18 Microservices with Docker and Kubernetes

 

This chapter covers

  • Running Camel on Docker
  • Getting started with Kubernetes
  • Running and debugging Camel on Kubernetes
  • Understanding essential Kubernetes concepts
  • Building resilient microservices on Kubernetes
  • Testing Camel microservices on Kubernetes
  • Introducing fabric8, Kubernetes Helm, and OpenShift

If you’ve been developing Java applications for many years, the transition to running them on the cloud is a big leap. You not only need to learn and master new concepts and primitives from the container-based world, you also make an architectural change from a monolithic to a microservice style.

As a developer, this can be a daunting mountain to climb, so in this chapter we’ll help you focus on one thing at a time and climb that mountain step by step. We’ll be in the developer role and show you how to develop, build, and run Camel microservices on Docker and Kubernetes all running locally on your computer.

You aren’t required to use any on-premises cluster infrastructure or sign up with an online cloud provider. As developers, we feel comfortable if we have control and can do it all from our own computers. You don’t have to worry about whether your computer is powerful enough, because what we’ll do can run on any reasonable computer. At the time of this writing, the author of this chapter is using a four-year-old MacBook Air equipped with only 8 GB of memory and a mediocre CPU.

18.1 Getting started with Camel on Docker

18.1.1 Building and running Camel microservices locally

18.1.2 Building and running Camel microservices using Docker

18.1.3 Building a Docker image using the Docker Maven plugin

18.1.4 Running Java microservices on Docker

18.2 Getting started with Kubernetes

18.2.1 Installing Minikube

18.2.2 Starting Minikube

18.3 Running Camel and other applications in Kubernetes

18.3.1 Running applications using kubectl

18.3.2 Calling a service running inside a Kubernetes cluster

18.3.3 Running Java applications in Kubernetes using Maven tooling

18.3.4 Java microservices calling each other in the cluster

18.3.5 Debugging Java applications in Kubernetes

18.4 Understanding Kubernetes

18.4.1 Introducing Kubernetes

18.4.2 Kubernetes architecture

18.4.3 Essential Kubernetes concepts

18.5 Building resilient Camel microservices on Kubernetes

18.5.1 Scaling up microservices

18.5.2 Using readiness and liveness probes

18.5.3 Dealing with failures by calling services in Kubernetes

18.6 Testing Camel microservices on Kubernetes

18.6.1 Setting up Arquillian Cube

18.7.1 fabric8