Hands-On Docker for Microservices with Python
Jaime Buelta更新时间:2021-06-24 12:36:37
最新章节:Leave a review - let other readers know what you thinkcoverpage
Title Page
Copyright and Credits
Hands-On Docker for Microservices with Python
Dedication
About Packt
Why subscribe?
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Code in Action
Conventions used
Get in touch
Reviews
Section 1: Introduction to Microservices
Making the Move – Design Plan and Execute
Technical requirements
The traditional monolith approach and its problems
The characteristics of a microservices approach
Docker containers
Container orchestration and Kubernetes
Parallel deployment and development speed
Challenges and red flags
Analyzing the current system
Preparing and adapting by measuring usage
Strategic planning to break the monolith
The replacement approach
The divide approach
Change and structured approach
Executing the move
Web services' best friend – the load balancer
Keeping the balance between new and old
The pilot phase – setting up the first couple of microservices
The consolidation phase – steady migration to microservices
The final phase – the microservices shop
Summary
Questions
Further reading
Section 2: Designing and Operating a Single Service – Creating a Docker Container
Creating a REST Service with Python
Technical requirements
Analyzing the Thoughts Backend microservice
Understanding the security layer
Designing the RESTful API
Specifying the API endpoints
Defining the database schema
Working with SQLAlchemy
Implementing the service
Introducing Flask-RESTPlus
Handling resources
Parsing input parameters
Serializing results
Performing the action
Authenticating the requests
Testing the code
Defining the pytest fixtures
Understanding test_token_validation.py
test_thoughts.py
Summary
Questions
Further reading
Build Run and Test Your Service Using Docker
Technical requirements
Building your service with a Dockerfile
Executing commands
Understanding the Docker cache
Building a web service container
Configuring uWSGI
Refreshing Docker commands
Operating with an immutable container
Testing the container
Creating a PostgreSQL database container
Configuring your service
Deploying the Docker service locally
Pushing your Docker image to a remote registry
Obtaining public images from Docker Hub
Using tags
Pushing into a registry
Summary
Questions
Further reading
Creating a Pipeline and Workflow
Technical requirements
Understanding continuous integration practices
Producing automated builds
Knowing the advantages of using Docker for builds
Leveraging the pipeline concept
Branching merging and ensuring a clear main build
Configuring Travis CI
Adding a repo to Travis CI
Creating the .travis.yml file
Working with Travis jobs
Sending notifications
Configuring GitHub
Pushing Docker images from Travis CI
Setting the secret variables
Tagging and pushing builds
Tagging and pushing every commit
Summary
Questions
Further reading
Section 3:Working with Multiple Services – Operating the System through Kubernetes
Using Kubernetes to Coordinate Microservices
Technical requirements
Defining the Kubernetes orchestrator
Comparing Kubernetes with Docker Swarm
Understanding the different Kubernetes elements
Nodes
Kubernetes Control Plane
Kubernetes Objects
Performing basic operations with kubectl
Defining an element
Getting more information
Removing an element
Troubleshooting a running cluster
Summary
Questions
Further reading
Local Development with Kubernetes
Technical requirements
Implementing multiple services
Describing the Users Backend microservice
Describing the Frontend microservice
Connecting the services
Configuring the services
Configuring the deployment
Configuring the service
Configuring the Ingress
Deploying the full system locally
Deploying the Users Backend
Adding the Frontend
Summary
Questions
Further reading
Configuring and Securing the Production System
Technical requirements
Using Kubernetes in the wild
Creating an IAM user
Setting up the Docker registry
Creating the cluster
Creating the Kubernetes cluster
Configuring the cloud Kubernetes cluster
Configuring the AWS image registry
Configuring the usage of an externally accessible load balancer
Deploying the system
Using HTTPS and TLS to secure external access
Being ready for migration to microservices
Running the example
Deploying a new Docker image smoothly
The liveness probe
The readiness probe
Rolling updates
Autoscaling the cluster
Creating a Kubernetes Horizontal Pod Autoscaler
Deploying the Kubernetes metrics server
Configuring the resources in deployments
Creating an HPA
Scaling the number of nodes in the cluster
Deleting nodes
Designing a winning autoscaling strategy
Summary
Questions
Further reading
Using GitOps Principles
Technical requirements
Understanding the description of GitOps
Managing configuration
Understanding DevOps
Defining GitOps
Setting up Flux to control the Kubernetes cluster
Starting the system
Configuring Flux
Configuring GitHub
Forking the GitHub repo
Adding a deploy key
Syncing Flux
Making a Kubernetes cluster change through GitHub
Working in production
Creating structure
Using GitHub features
Working with tags
Summary
Questions
Further reading
Managing Workflows
Understanding the life cycle of a feature
Features that affect multiple microservices
Implementing a feature
Reviewing and approving a new feature
Reviewing feature code
Approving releases
Setting up multiple environments
Scaling the workflow and making it work
Reviewing and approving is done by the whole team
Understanding that not every approval is the same
Defining a clear path for releases
Emergency releases
Releasing frequently and adding feature flags
Using feature flags
Dealing with database migrations
Summary
Questions
Further reading
Section 4: Production-Ready System – Making It Work in Real-Life Environments
Monitoring Logs and Metrics
Technical requirements
Observability of a live system
Understanding logs
Understanding metrics
Setting up logs
Setting up an rsyslog container
Defining the syslog pod
log-volume
syslog container
The front rail container
Allowing external access
Sending logs
Generating application logs
Dictionary configuration
Logging a request ID
Logging each request
Searching through all the logs
Detecting problems through logs
Detecting expected errors
Capturing unexpected errors
Logging strategy
Adding logs while developing
Setting up metrics
Defining metrics for the Thoughts Backend
Adding custom metrics
Collecting the metrics
Plotting graphs and dashboards
Grafana UI
Querying Prometheus
Updating dashboards
Being proactive
Alerting
Being prepared
Summary
Questions
Further reading
Handling Change Dependencies and Secrets in the System
Technical requirements
Understanding shared configurations across microservices
Adding the ConfigMap file
Using kubectl commands
Adding ConfigMap to the deployment
Thoughts Backend ConfigMap configuration
Users Backend ConfigMap configuration
Frontend ConfigMap configuration
Handling Kubernetes secrets
Storing secrets in Kubernetes
Creating the secrets
Storing the secrets in the cluster
Secret deployment configuration
Retrieving the secrets by the applications
Defining a new feature affecting multiple services
Deploying one change at a time
Rolling back the microservices
Dealing with service dependencies
Versioning the services
Semantic versioning
Adding a version endpoint
Obtaining the version
Storing the version in the image
Implementing the version endpoint
Checking the version
Required version
The main function
Checking the version
Summary
Questions
Further reading
Collaborating and Communicating across Teams
Keeping a consistent architectural vision
Dividing the workload and Conway's Law
Describing Conway's Law
Dividing the software into different kinds of software units
Designing working structures
Structuring teams around technologies
Structuring teams around domains
Structuring teams around customers
Structuring teams around a mix
Balancing new features and maintenance
Regular maintenance
Understanding technical debt
Continuously addressing technical debt
Avoiding technical debt
Designing a broader release process
Planning in the weekly release meeting
Reflecting on release problems
Running post-mortem meetings
Summary
Questions
Further reading
Assessments
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Other Books You May Enjoy
Leave a review - let other readers know what you think
更新时间:2021-06-24 12:36:37