@chimpwizard/lab

1.0.2 • Public • Published

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>

Readme

Keywords

none

Package Sidebar

Install

npm i @chimpwizard/lab

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

44.6 kB

Total Files

19

Last publish

Collaborators

  • ndruwizz