Skip to content

An exploration into the possibilities for exact environment replication between local and cloud locations, for the purposes of making development faster and easier.

License

Notifications You must be signed in to change notification settings

nubbthedestroyer/hashicorp-env-portability

Repository files navigation

Hashicorp Environment Portability

An exploration into the possibilities for exact environment replication between local and cloud locations, for the purposes of making development faster and easier.

Synopsis

It is a VERY common issue in modern development, particularly with the adoption of Service Oriented Architectures and complex devops practices, that highly distributed environments are very difficult to replicate locally for development. Some tools are helpful but require differences in production that are difficult to replicate locally. Take Docker, for example, which makes it very easy to create and collaborate on system configuration, but lacks built in service discovery and load balancing features. The purpose of this repo is to explore ways that we can simplify the translation of a full microservices infrastructure between production and development by providing a framework that developers can use to build microservices using Consul, Nomad, and Terraform.

Prerequisites

This framework requires the following to work properly:

  • AWS CLI tools
  • Vagrant
    • We will need the Vagrant binary to be in path so we can bring everything up.
    • This entire environment will run in and through Vagrant and AWS, simplifying the system requirements to launch this cluster.

Let's Launch it!

Firstly, we need to clone this repo:

git clone https://github.com/nubbthedestroyer/hashicorp-env-portability.git

In order to bring up the vagrant instance while passing it some variables, we need to use a script to do it.

This script is named "build-vagrant.sh" located at the root of the repo. Lets run it.

cd hashicorp-env-portability
./build-vagrant.sh

You will be asked about which network you want to use for the bridge. Chose a network that will be exposed to a DHCP server so the box can get a network IP. This is important for the local dev environment. This install will take some time, as Vagrant will need to download and provision the box. After this is complete you should be dropped into an SSH session on the vagrant box. If you made it so far, then GREAT! Next, let's start the united cluster build automation:

cd /vagrant
> ./build-all-clusters.sh

This script has a lot to do. For more information regarding each step, take a look at "./build-all-clusters.sh". There is some bash magic involved in making this launch as smooth as possible, but much can be learned from following the way the clusters are configured. This is not a production ready environment, but it could be a first step towards that.

After this script finishes, you should see a list of addresses generated by "./get-addresses.sh". If you don't see the "Hello World 1+2" endpoints or you dont see all three, wait another minute and run "./get-addresses.sh". The list of addresses should look something like this:

Go check out your AWS application:

Consul Endpoint = http://54.89.157.23:8500/ui/
Nomad Endpoint = http://54.205.105.38:4646/

Hello World 1: = http://35.168.2.6:8080/
Hello World 1: = http://52.54.54.152:8080/
Hello World 1: = http://54.159.94.204:8080/


Hello World 2: = http://54.159.94.204:8082/
Hello World 2: = http://52.54.54.152:8082/
Hello World 2: = http://35.168.2.6:8082/


Go check out your application running locally in vagrant at the following endpoints:

Consul Endpoint = http://192.168.1.21:8500/ui/
Nomad Endpoint = http://192.168.1.21:4646/
Hello World 1 = http://192.168.1.21:8080/
Hello World 2 = http://192.168.1.21:8082/

Try going to some of the links and observe the outputs indicating where it is hosted and which microservice it is.

This environment should prove to be a great base for those learning about Nomad and Consul and provides a zero configuration working environment to reverse engineer, which is definitely the way I learn. Any ideas for improvement are welcome. Hope you enjoyed it!

About

An exploration into the possibilities for exact environment replication between local and cloud locations, for the purposes of making development faster and easier.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published