diff --git a/.gitignore b/.gitignore index a6974b8..7bc08b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # vagrant data directories cluster/.vagrant +cluster/.etc_hosts +cluster/.cfg.yml diff --git a/Makefile b/Makefile index e40423f..f9a1b76 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ release: # Brings up a demo cluster to install Contiv on - by default this is a docker, centos cluster. # It can be configured to start a RHEL cluster by setting CONTIV_NODE_OS=rhel7. -# It can be started with k8s kubeadm install by running with VAGRANT_USE_KUBEADM=1. +# It can be started with k8s kubeadm install by running with CONTIV_KUBEADM=1. cluster: cluster-destroy cd cluster && vagrant up @@ -20,20 +20,27 @@ cluster-destroy: # demo-k8s brings up a cluster with k8s, runs the installer on it, and shows the URL # of the demo Contiv Admin Console which was set up demo-k8s: - @bash ./scripts/demo-k8s.sh + CONTIV_KUBEADM=1 make cluster + BUILD_VERSION=1.0.0-beta.2 make install-test-kubeadm + +# demo-swarm brings up a cluster with docker swarm, runs the installer on it, and shows the URL +# of the demo Contiv Admin Console which was set up +demo-swarm: + make cluster + BUILD_VERSION=1.0.0-beta.2 make install-test-swarm # Create a release and test the release installation on a vagrant cluster # TODO: The vagrant part of this can be optimized by taking snapshots instead # of creating a new set of VMs for each case release-test-kubeadm: release # Test kubeadm (centos by default) - VAGRANT_USE_KUBEADM=1 make cluster - VAGRANT_USE_KUBEADM=1 make install-test-kubeadm + CONTIV_KUBEADM=1 make cluster + CONTIV_KUBEADM=1 make install-test-kubeadm release-test-swarm: release # Test swarm (centos by default) - CLUSTER_CONFIG='cluster_defs_ansible.json' make cluster - CLUSTER_CONFIG='cluster_defs_ansible.json' make install-test-swarm + make cluster + make install-test-swarm release-test-kubelegacy: release # Test k8s ansible (centos by default) diff --git a/QUICKSTART.md b/QUICKSTART.md new file mode 100644 index 0000000..84cda8f --- /dev/null +++ b/QUICKSTART.md @@ -0,0 +1,32 @@ +# Quick Start Guide + +## Pre-requisites + +* [Install Virtual Box 5.1.14 or later]( https://www.virtualbox.org/wiki/Downloads ) +* [Install Vagrant 1.9.1 or later]( https://www.vagrantup.com/downloads.html ) +* [Install Docker 1.12 or later]( https://docs.docker.com/engine/installation/ ) +* Clone the Contiv install repository
+`git clone http://github.com/contiv/install' + +## Setup the cluster with Contiv for Kubernetes +`make demo-k8s` + +## Setup the cluster with Contiv for Docker with Swarm +`make demo-swarm` + +## Customizing the setup + +* The default configuration creates a 2 node cluster. To increase the number of nodes set the environment variable `CONTIV_NODES=` + +## Quick Start Guide for CentOS 7.x hosts + +* Setup the pre-requisites as follows and follow the demo instructions above +``` + wget https://releases.hashicorp.com/vagrant/1.9.1/vagrant_1.9.1_x86_64.rpm + wget http://download.virtualbox.org/virtualbox/5.1.14/VirtualBox-5.1-5.1.14_112924_el7-1.x86_64.rpm + sudo yum install VirtualBox-5.1-5.1.14_112924_el7-1.x86_64.rpm -y + sudo yum install vagrant_1.9.1_x86_64.rpm -y + sudo yum install docker -y + sudo systemctl start docker + git clone http://github.com/contiv/install +``` diff --git a/cluster/Vagrantfile b/cluster/Vagrantfile index f7b7194..61be40c 100755 --- a/cluster/Vagrantfile +++ b/cluster/Vagrantfile @@ -1,116 +1,137 @@ -# -*- mode: ruby -*- + # -*- mode: ruby -*- # vi: set ft=ruby : require 'rubygems' -require 'json' require 'fileutils' +require 'yaml' token = 'd900e1.8a392798f13b33a4' # method to create an etc_hosts file based on the cluster info -def create_etc_hosts(cluster) - master_ip = '192.168.2.10' +def create_etc_hosts(num_nodes, base_ip, start) + master_ip = base_ip + start.to_s hosts = "127.0.0.1 localhost\n" - cluster.each do |role, member_list| - hosts = member_list.inject(hosts) { |acc, elem| acc << "#{elem['contiv_control_ip']} #{elem['name']}\n" } - if role == 'master' && member_list[0] - hosts << "#{member_list[0]['contiv_control_ip']} netmaster\n" - master_ip = member_list[0]['contiv_control_ip'] - end - end + hosts << "#{master_ip} netmaster\n" + hosts = (0..num_nodes).inject(hosts) { |acc, elem| acc << base_ip + "#{elem + start} contiv-node#{elem + 1} \n" } - etc_file = (ENV['VAGRANT_CWD'] || '.') + '/export/.etc_hosts' + etc_file = (ENV['VAGRANT_CWD'] || '.') + '/.etc_hosts' File.write(etc_file, hosts) master_ip end +# method to create an cfg file based on the cluster info +def create_cfg_info(num_nodes, node_ips) + conn = {} + num_nodes.times do |n| + node_ip = node_ips[n] + node = if n.zero? + { 'role' => 'master' } + else + {} + end + node['control'] = ENV['CONTIV_CONTROL_IF'] || 'eth1' + node['data'] = ENV['CONTIV_DATA_IF'] || 'eth2' + conn[node_ip] = node + end + cfg_data = { 'CONNECTION_INFO' => conn } + cfg_file = (ENV['VAGRANT_CWD'] || '.') + '/.cfg.yml' + File.write(cfg_file, cfg_data.to_yaml) +end + provision_node = <