Chapter 10. Deploying your microservices
The chapter emphasizes that deployment is a core part of microservices success, not an afterthought. Because microservices are meant to be small, independently changeable units, the path from code change to production should be fast, automated, repeatable, and fully controlled by scripts. The chapter frames this around DevOps practices and the idea that developers should own more of the operational responsibility for building, packaging, and deploying their services.
Using the EagleEye system as an example, the chapter walks through setting up the cloud foundation needed to run the services on Amazon. It separates the database and cache into managed Amazon services, creates an ECS cluster for the Dockerized microservices, and configures networking and security so traffic flows through the API gateway rather than directly to the services. The discussion also shows how application settings are updated through external configuration so the services can connect to the new cloud-based infrastructure.
The second half focuses on deployment workflows, first by showing a manual ECS deployment and then by automating the process with a CI/CD pipeline. The pipeline uses source control tagging, Maven builds, Docker image creation, Docker Hub publishing, ECS deployment, and post-deployment platform tests to verify that the system works in its target environment. Along the way, the chapter stresses immutable servers, infrastructure as code, traceability, and the value of running tests after deployment to catch problems that unit and integration tests cannot reveal.
Figure 10.1. By using Docker, all your services can be deployed to a cloud provider such as Amazon ECS.
Figure 10.6. With a few clicks you can set up a Redis cluster whose infrastructure is managed by Amazon.
Figure 10.7. The Redis endpoint is the key piece of information your services need to connect to Redis.
Figure 10.10. In the “Create Cluster” screen size the EC2 instances used to host the Docker cluster.
Figure 10.11. Once the servers are set up, configure the network/AWS security groups used to access them.
Figure 10.15. Each component in the build and deployment pipeline automates a task that would have been manually done.
Summary
- The build and deployment pipeline is a critical part of delivering microservices. A well-functioning build and deployment pipeline should allow new features and bug fixes to be deployed in minutes.
- The build and deployment pipeline should be automated with no direct human interaction to deliver a service. Any manual part of the process represents an opportunity for variability and failure.
- The build and deployment pipeline automation does require a great deal of scripting and configuration to get right. The amount of work needed to build it shouldn’t be underestimated.
- The build and deployment pipeline should deliver an immutable virtual machine or container image. Once a server image has been created, it should never be modified.
- Environment-specific server configuration should be passed in as parameters at the time the server is set up.