paint-brush
1-Minute Multi-Node VM Setup by@zwischenzugs
1,755 reads
1,755 reads

1-Minute Multi-Node VM Setup

by Ian MiellDecember 8th, 2016
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Quickly spin up multiple VMs with useful DNSs on your local machine and automate complex environments easily.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - 1-Minute Multi-Node VM Setup
Ian Miell HackerNoon profile picture

tl;dr

Quickly spin up multiple VMs with useful DNSs on your local machine and automate complex environments easily.

Here’s a video:


Introduction

Maintaining Docker at scale, I’m more frequently concerned with clusters of VMs than the containers themselves.

The irony of this is not lost on me. Frequently I need to spin up clusters of machines. Either this is very slow/unreliable (Enterprise OpenStack implementation) or expensive (Amazon).

The obvious answer to this is to use Vagrant, but managing this can be challenging.

So I present here a very easy way to set up a useful Vagrant cluster. With this framework, you can then automate your ‘real’ environment and play to your heart’s content.


$ pip install shutit$ shutit skeleton


# Input a name for this module.# Default: /Users/imiell/shutit_resins

[hit return to take default]







# Input a ShutIt pattern.Default: bashbash: a shell scriptdocker: a docker image buildvagrant: a vagrant setupdocker_tutorial: a docker-based tutorialshutitfile: a shutitfile-based project

[type in vagrant]

vagrant

How many machines do you want (default: 3)? 3

[hit return to take default]

What do you want to call the machines (eg superserver) (default: machine)?

[hit return to take default]

Do you want to have open ssh access between machines? (default: yes) yes








Initialized empty Git repository in /Users/imiell/shutit_resins/.git/Cloning into ‘shutit-library’...remote: Counting objects: 1322, done.remote: Compressing objects: 100% (33/33), done.remote: Total 1322 (delta 20), reused 0 (delta 0), pack-reused 1289Receiving objects: 100% (1322/1322), 1.12 MiB | 807.00 KiB/s, done.Resolving deltas: 100% (658/658), done.Checking connectivity… done.



# Run:cd /Users/imiell/shutit_resins && ./run.shto run.

[follow the instructions to run up your cluster.

$ cd /Users/imiell/shutit_resins && ./run.sh

This will automatically run up an n-node cluster and then finish up. NOTE: Make sure you have enough resources on your machine to run this! BTW, if you re-run the run.sh it automatically clears up previous VMs spun up by the script to prevent your machine grinding to a halt with old machines.


Going deeper

What you can do from there is automate the setup of these nodes to your needs. For example:


def build(self, shutit):[... go to end of this function ...]






# Install apacheshutit.login(command='vagrant ssh machine1')shutit.login(command='sudo su - ')shutit.install('apache2')shutit.logout()shutit.logout()







# Go to machine2 and call machine1's servershutit.login(command='vagrant ssh machine2')shutit.login(command='sudo su -')shutit.install('curl')shutit.send('curl machine1.vagrant.test')shutit.logout()shutit.logout()

Will set up an apache server and curl a request to the first machine from the second.

Examples

This is obviously a simple example. I’ve used this for these more complex setups which are can be instructive and useful:

Chef server and client

Creates a chef server and client.


Docker Swarm

Creates a 3-node docker swarm


OpenShift Cluster

This one sets up a full OpenShift cluster, setting it up using the standard ansible scripts.


Automation of an etcd migration on OpenShift

This branch of the above code sets up OpenShift using the alternative Chef scripts, and migrates an etcd cluster from one set of nodes to another.


Docker Notary

Setting up of a Docker notary sandbox.


Help Wanted

If you have a need for an environment, or can improve the setup of any of the above please let me know: @ianmiell

Learn More

My book :

DIP

Get 39% off with the code: 39miell

바카라사이트 바카라사이트 온라인바카라