anchor.diff:  ---
   layout: post
  -title: Continuous Delivery of Microservices - Environment Strategy
  +title: Environment Strategy for Continuous Delivery of Microservices
   type: post
   author: Sheroy Marker
  -excerpt: "Getting deeper into CD practices, we'll cover continuous integration, feature toggles, and the importance of trunk based development"
  +excerpt: "In this post, we'll look at environment strategy including artifact promotion and leveraging modern infrastructure for dynamic environments."
   summary_image: "/assets/images/blog/cd-considerations/cd-microservices-environment-strategy.jpg"
  -title_tag_of_header: "Continuous Delivery of Microservices - Trunk Based Development and Feature Toggles | GoCD Blog"
  +title_tag_of_header: "Continuous Delivery of Microservices - Environment Strategy | GoCD Blog"
   meta_description: "You can start with thinking about what environments need to be created upfront and talking about the intended use cases for these environments. Different groups in your organization will have different competing needs. Your environment plan should accommodate the needs from different parties."
   meta_keywords: "Microservices, continuous delivery, microservice environment, environment strategy, artifacts, provision environment"
   tags: CD for Microservices
  
positive.code: 
  <img src="/assets/images/blog/cd-considerations/environments-plan.jpeg" alt="Environment Plan for Continuous Delivery"/>
      
  The diagram above shows you an environment plan. From the plan you can see how many environments exist in the CD pipeline, the different colored arrows depict different artifact promotion strategies. Early on in this pipeline, we generate artifacts that go to a different artifact repository that has a more aggressive clean-up strategy, so we don't really retain too many of those environments. As you go further down this pipeline, your artifacts are verified and more robust and you want to keep these for a little longer, so you keep them in a different store with a different retention policy.
  
  ##Dynamic environments 
  
  Environments are expensive and cumbersome to maintain. One way to make the process simpler and less expensive is to create environments on the fly. For example, when running functional tests, you can provision a functional test environment on demand, then clean it up right after your test is done. 
  
  To do this, you need use IaaC techniques to script all aspects of environment provisioning. Here are the benefits of doing this:
  
  **Parity with production**
  If you create all environments dynamically based on automation, you will use exactly the same way to create testing and staging environments. The scale and nature of infrastructure may be different, but the footprint of the environment remains the same. 
  
negative.code: 
  In some organizations people don’t realize the importance of an environment plan until they have too many environments and maintaining them becomes overwhelming. 
  
  An environment plan communicates the various environments that are involved in the path to production and their intended uses. It also communicates how your artifacts are promoted and the toggle states on these environments.
  
  You can start with thinking about what environments need to be created upfront and talking about the intended use cases for these environments. Different groups in your organization will have different competing needs. Your environment plan should accommodate the needs from different parties. 
  
  