concept environment variable in category microservice

appears as: environment variables, environment variables, n environment variable
Bootstrapping Microservices with Docker, Kubernetes and Terraform

This is an excerpt from Manning's book Bootstrapping Microservices with Docker, Kubernetes and Terraform.

We’ll talk more about ways we can test our microservices in Chapter 8: Automated testing for microservices.

export PORT=3000

Before running the new microservice we need to set the environment variables to configure it. We will do this from the terminal. On MacOS and Linux we do it like this:

Microservices Security in Action

This is an excerpt from Manning's book Microservices Security in Action.

The first line of Dockerfile-2 instructs Docker to fetch the Docker image called openjdk:8-jdk-alpine from the Docker registry and, in this case, from the public Docker Hub. This is the base image of the Docker image we want to create. The second line instructs Docker to copy the file com.manning.mss.ch10.sample01-1.0.0.jar from the target directory of the host filesystem to the root of the container filesystem. The third line instructs Docker to create an environment variable called SPRING _CONFIG_LOCATION and point it to the /opt/application.properties file. The process running inside the container reads this environment variable to find the location of the application.properties file; then it looks for the file under the /opt directory of the container filesystem. Finally, the fourth line tells Docker the entry point to the container, or which process to run when we start the container.

The straightforward way to carry configuration data in a Kubernetes Deployment is to hardcode the data into the definition of the Deployment as environment variables. For example, we can modify the command we used in section J.6 to create a Deployment to pass some configuration data as environment variables in the command line:

Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito

This is an excerpt from Manning's book Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito.

Windows users may find the following link useful for configuring environment variables: http://mng.bz/1a2K.[1]

Client connections as environment variables

It’s good practice to configure URLs for client connections via environment variables, and to provide a default/fallback value. Although this can’t be considered a pattern, it’s a good practice to pick up when you’re developing microservices.

In our experience, the best way to configure client connections is to use environment variables, because they’re simple to define and are supported by the native OS, build tools, and system-configuration scripts. You don’t need to reinvent the wheel.