liveBook · Manning

Production-like environment

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A production-like environment is a nonproduction environment configured to approximate the operational conditions of production.

A production-like environment approximates production without serving customers. It gives a team a place to test integrated changes before release and to investigate problems that are difficult to reproduce on a development computer. section 12.2.5 section 11.3.1

A typical workflow moves changes from a developer’s computer through integration and test environments before they reach the customer-facing environment. Local testing alone cannot check how one developer’s changes behave when integrated with others’ work. section 12.2.5

For a bug too complex to reproduce locally, first document steps that reliably reproduce it in the test environment. Experiment to identify the components involved, then remove those that do not contribute until the application is small enough to run locally. An automated test that initially fails can confirm that the bug is reproducible and later verify the fix. section 11.3.1

Create separate environments with Terraform

Parameterize the environment name and derive the application name from it. Different values can create separate development, test, and production instances from the existing Terraform configuration. section 12.2.5

Listing 12.2 Deriving app_name from environment in Terraform
variable “environment” {}                     #1
 
locals {
  app_name = “flixtube-${var.environment}”    #2
}

This listing derives the application name from the environment variable. section 12.2.5

A local Kubernetes deployment can also simulate a production-like setting, but it is not the same as running in production. Testing in a production-like environment improves realism without making the environment customer-facing. section 6.8.9 section 12.2.5

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Describes a testing and debugging workflow and parameterizes environments with Terraform, while distinguishing local simulation from actual production.
Examples
Uses separate Terraform application instances and a video-streaming microservice deployed to local Kubernetes.
What you can do after
Apply it via Terraform by selecting an environment variable to create separately named application instances.
How it connects
Connects integrated testing, debugging, automated tests, microservices, and deployment workflows.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.