Product
|
Cloud costs
|
released
February 14, 2023
|
3
min read
|

Using Ephemeral Environments to Test and Scale Your Deployments

Updated

The world of DevOps today is characterized by exciting new approaches and tools revolving around developer experience and productivity. Gone are the days when manual testing and deployment used to take days to complete. These new tools automate and streamline the software development pipeline. Typically, whenever any application is created, it’s entered into a continuous integration (CI) tool or platform that tests the code through various frameworks. If the tests are passed, the code will be deployed. 

However, increasing velocity is difficult if your processes and tools are tedious and complex to  configure. That’s why ease of use is non-negotiable for every developer evaluating any new tool. Developers like a CI tool that’s not only easy to set up but can also scale to test their applications. Configuring infrastructure and other related tasks is daunting and time-consuming, taking resources away from deployments. 

This is where a concept called ephemeral environments comes in. Ephemeral environments can be used to test your applications much faster by spinning up environment instances that are short-lived and automatically destroyed after the work is done. In this tutorial, we will discuss what ephemeral environments are, how they work, and how to configure them. 

What are Ephemeral Environments?

Ephemeral environments are an excellent way for engineering and development teams to collaborate and test new features quickly and efficiently. They provide a temporary, isolated environment for running tests and previewing features without worrying about making any permanent changes that may impact production systems. This allows for rapid iteration and development without committing to long-term changes. 

Virtual machines in the production pipeline

Configuring an ephemeral environment allows you to customize the environment to meet specific needs and preferences, such as the preferred operating system, number of servers, or type of memory and storage. Once the environment is set up, you can utilize that environment to run tests and experiments on your application. 

Running an application in an ephemeral environment is relatively simple. All of the necessary files and configurations will be packaged into a single deployable artifact. This can then be deployed to the ephemeral environment and quickly spun up, allowing for rapid application development and testing. 

The process is usually automated, allowing for continuous deployments and the environment to be easily rolled back if necessary. Additionally, the process can be configured to run certain tests or other checks before the deployment is finalized. This helps ensure that the application runs as expected and is free of errors or issues.

Advantages of Ephemeral Environments

Overall, ephemeral environments provide a robust, on-demand platform for quickly testing and previewing new features. Let’s dive into some of their distinct advantages over traditional static or shared staging environments.

Asynchronous Collaboration

Ephemeral environments make it easier for teams to collaborate asynchronously. This is especially useful when teams are distributed across different time zones. Setting up an ephemeral environment allows teams to share their work and collaborate on projects without having to work at the same time. They are also commonly used for previewing features as teams can quickly spin up a new environment to test out new ideas without affecting existing services.

Cost Effective

Ephemeral environments are cost-effective, simple to set up, and can be destroyed and recreated when needed, making them an excellent choice for teams collaborating across multiple projects. They give the developers temporary environments that can be efficiently utilized to test and experiment and destroy after the experiment is finished. Developers don’t need to worry about adding additional costs by running resources directly from their cloud providers.  

Agile and Flexible

The ephemeral environment is far more agile and flexible than conventional environments, allowing developers to quickly spin up an instance of their application with the exact specifications they need. This makes it easier to deploy and test changes without waiting for a new application version to be built and deployed. Additionally, ephemeral environments allow teams to quickly scale up their applications to meet the demands of their users and reduce operational costs by automatically shutting down instances that are no longer needed. Finally, ephemeral environments also provide increased security and reliability, as they are entirely isolated from other instances and automatically destroyed after a specific period.

How to Create an Ephemeral Environment Using Harness

With Harness, you can setup and configure ephemeral environments automatically. With just a click of a button, you will be presented with an environment to utilize. Harness offers hosted virtual machines (VMs) to run your builds, so you can test and build your code without worrying about setting up anything. Harness can provide the infrastructure, so you can focus on developing great software.

First, sign up for the Harness free account and create a project and select the CI module.

Harness CI

Click on Get Started to create your pipeline. 

Get started with the pipeline

Connect your code repository.

Select code repository

(I am using this Simple-Node-App repository. You can fork the same and use it in this tutorial. It has a simple test case.)

By default, the pipeline is configured for you with a simple Echo Welcome Message in the execution step.

Build the pipeline

If you click on the Echo Welcome Message step, you will see the configuration.

Configure run

Now you have your ephemeral environment to test our application. 

If you click on the Infrastructure tab, you can see the options: VMs and Kubernetes.

We will select VMs as our choice since we are going to use them as our infrastructure to test and build our application. You can select from the range of operating systems available, such as Linux, macOS, and Windows. We have selected Linux for our tutorial here. 

Select Linux for the infrastructure

You can click continue and save the pipeline.

When you save and execute this pipeline, you will see the output that prints Welcome to Harness CI.

Welcome Harness output

You can edit the pipeline to add the ‘run test’ step under execution. We will see how a run step can be configured using the ephemeral environment.

Add a step and select the ‘Run’ step.

Run step

Configure the Run step as below:

Configure run

At this point, your pipeline looks like this:

Pipeline for ephemeral environment

Now, save and run the pipeline. You can see that both -- the default Echo Welcome Message and the newly added Run Test steps are successfully getting executed. 

We can now make use of multiple environments to add more tests and to experiment with our application. 

Build and Test Faster with Ephemeral Environments

Organizations need to find ways to speed up the software deployment process in order to compete in today’s highly competitive software market, and doing so involves making developers' lives easier by providing them with the necessary tools and knowledge. Using ephemeral environments is a best practice to ensure your applications are tested and deployed at speed without worrying about the underlying infrastructure and its setup. When executing a pipeline on Harness, your builds run on VMs that contain the required settings, so you can start building and testing your applications in no time. 

Learn more about Harness CI, try it for free today, and check out the Harness Developer Hub for more product tutorials. 

Sign up now

Sign up for our free plan, start building and deploying with Harness, take your software delivery to the next level.

Get a demo

Sign up for a free 14 day trial and take your software development to the next level

Documentation

Learn intelligent software delivery at your own pace. Step-by-step tutorials, videos, and reference docs to help you deliver customer happiness.

Case studies

Learn intelligent software delivery at your own pace. Step-by-step tutorials, videos, and reference docs to help you deliver customer happiness.

We want to hear from you

Enjoyed reading this blog post or have questions or feedback?
Share your thoughts by creating a new topic in the Harness community forum.

Sign up for our monthly newsletter

Subscribe to our newsletter to receive the latest Harness content in your inbox every month.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Continuous Integration