Book Image

Hands-On Docker for Microservices with Python

By : Jaime Buelta
Book Image

Hands-On Docker for Microservices with Python

By: Jaime Buelta

Overview of this book

Microservices architecture helps create complex systems with multiple, interconnected services that can be maintained by independent teams working in parallel. This book guides you on how to develop these complex systems with the help of containers. You’ll start by learning to design an efficient strategy for migrating a legacy monolithic system to microservices. You’ll build a RESTful microservice with Python and learn how to encapsulate the code for the services into a container using Docker. While developing the services, you’ll understand how to use tools such as GitHub and Travis CI to ensure continuous delivery (CD) and continuous integration (CI). As the systems become complex and grow in size, you’ll be introduced to Kubernetes and explore how to orchestrate a system of containers while managing multiple services. Next, you’ll configure Kubernetes clusters for production-ready environments and secure them for reliable deployments. In the concluding chapters, you’ll learn how to detect and debug critical problems with the help of logs and metrics. Finally, you’ll discover a variety of strategies for working with multiple teams dealing with different microservices for effective collaboration. By the end of this book, you’ll be able to build production-grade microservices as well as orchestrate a complex system of services using containers.
Table of Contents (19 chapters)
Free Chapter
1
Section 1: Introduction to Microservices
3
Section 2: Designing and Operating a Single Service – Creating a Docker Container
7
Section 3:Working with Multiple Services – Operating the System through Kubernetes
13
Section 4: Production-Ready System – Making It Work in Real-Life Environments

Technical requirements

If you're working with macOS or Windows, the default Docker desktop installation can start a local Kubernetes cluster. Just ensure that this is enabled in Kubernetes' preferences:

For Linux, the easiest way to install Kubernetes locally is to use k3s (https://k3s.io/).

k3s is a nod to Kubernetes (that is, k8s) but is a simplified version of it.

k3s is a minimalistic installation of Kubernetes that you can use to run a cluster contained in a single binary. Check out the installation page (https://github.com/rancher/k3s/blob/master/README.md) if you wish to download and run it.

To be able to use the Docker version that's running inside the k3s cluster, we need to use the following code:

$ # Install k3s
$ curl -sfL https://get.k3s.io | sh -
$ # Restart k3s in docker mode
$ sudo systemctl edit --full k3s.service
# Replace `ExecStart=/usr/local/bin...