@chimpwizard/lab
Vagrant lab
Last updated a year ago by ndruwizz .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @chimpwizard/lab 
SYNC missed versions from official npm registry.

Lab

by: иÐгü
email: ndru@chimpwizard.com
date: 10.1.2018
version: draft

One of the challenges for the developers when building scalable applications is to get an environment as close to the real production environment. The purpose of this library is to provide an easy mechanism to provision a cluster that can be use locally to test contenarized applications.

The implementation

The lab is provisioned usig vagrant encapsulating the complexity thru an easy to use cli.

The vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :
#^syntax detection


VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.8.1"
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

#
# Order matters b/c we need master kube.config on console
#
servers=[
  { :hostname => "master1", :ip => "172.10.10.20" },
  { :hostname => "console", :ip => "172.10.10.10" },
  { :hostname => "node1",   :ip => "172.10.10.30" },
  { :hostname => "node2",   :ip => "172.10.10.40" }
]

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  servers.each do |machine|
    config.vm.define machine[:hostname] do |node|
      node.vm.box = "bento/ubuntu-16.04"

      node.vm.hostname = machine[:hostname]
      node.vm.network "private_network", ip:machine[:ip]

      node.vm.provider :virtualbox do |vb|
        vb.memory=2048  # 4096
        vb.cpus = 1     # 4
      end

      if node.vm.hostname == "console"
        node.vm.synced_folder ".", "/home/app", owner: "vagrant", group: "vagrant"
        node.vm.provision "file", source: "./scripts", destination: "$HOME/scripts"
        node.vm.provision "file", source: "./samples", destination: "$HOME/samples"
        node.vm.provision "shell", privileged:false, path:"./scripts/vagrant/setup.sh", args:["#{servers[0][:ip]}","#{ENV['PLATFORM']}"]
      end

      if node.vm.hostname != "console"
        node.vm.provision "file", source: "./scripts", destination: "$HOME/scripts"
        node.vm.provision "shell", privileged:false, path:"./scripts/vagrant/setup.sh", args:["#{servers[0][:ip]}","#{ENV['PLATFORM']}"]
      end
    end
  end

end

Prerequisites to run the code

Quickstart

First you need to install the cli

npm install -g @chimpwizard/lab

to start the cluster

lab up --platform [swarm|k8s]

to connect to the console

lab ssh

to clean up your machine

lab down

Some references while doing this

Additional improvements

  • Add an additional feature to be able to specify the host OS environment
lab up --os [ubuntu|centos|debian|rhel|windows]
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-43465642-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-43465642-1'); </script>

Current Tags

  • 1.0.2                                ...           latest (a year ago)

3 Versions

  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 4
Last Month 0
Dependencies (6)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |