summaryrefslogtreecommitdiffstats
path: root/src/vagrant
diff options
context:
space:
mode:
Diffstat (limited to 'src/vagrant')
-rw-r--r--src/vagrant/README.md23
-rwxr-xr-xsrc/vagrant/setup_vagrant.sh62
-rw-r--r--src/vagrant/update.sh58
3 files changed, 120 insertions, 23 deletions
diff --git a/src/vagrant/README.md b/src/vagrant/README.md
deleted file mode 100644
index ed5f6c6..0000000
--- a/src/vagrant/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-Vagrant
-=======
-
-vagrant is to create kubernetes cluster using kubeadm.
-kubernetes installation by kubeadm can be refered to
-https://kubernetes.io/docs/getting-started-guides/kubeadm
-
-Vagrant Setup
--------------
-
-sudo apt-get install -y virtualbox
-wget --no-check-certificate https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6_x86_64.deb
-sudo dpkg -i vagrant_1.8.6_x86_64.deb
-
-K8s Setup
----------
-
-vagrant up
-
-K8s Cleanup
------------
-
-vagrant destroy -f
diff --git a/src/vagrant/setup_vagrant.sh b/src/vagrant/setup_vagrant.sh
new file mode 100755
index 0000000..a2ac72f
--- /dev/null
+++ b/src/vagrant/setup_vagrant.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+set -ex
+
+DIR="$(dirname `readlink -f $0`)"
+
+install_packages()
+{
+ cat << EOF | sudo tee /etc/sudoers.d/${USER}
+${USER} ALL = (root) NOPASSWD:ALL
+EOF
+ sudo apt-get update -y
+ sudo apt-get install -y git unzip
+ wget https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7_x86_64.deb
+ sudo dpkg -i vagrant_1.8.7_x86_64.deb
+ rm -rf vagrant_1.8.7_x86_64.deb
+
+ sudo apt-get install -y virtualbox
+
+ #refer to https://github.com/vagrant-libvirt/vagrant-libvirt
+ #sudo apt-get build-dep vagrant ruby-libvirt -y
+ sudo apt-get install -y bridge-utils qemu libvirt-bin ebtables dnsmasq
+ sudo apt-get install -y libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
+ vagrant plugin install vagrant-libvirt
+ sudo adduser ${USER} libvirtd
+ sudo service libvirtd restart
+}
+
+install_box_builder()
+{
+ # Thanks Bento's great effort
+ # Bento project(https://github.com/chef/bento) is released by Apache 2.0 License
+ cd $DIR
+ rm -rf bento
+ git clone https://github.com/chef/bento
+ cd bento; git checkout 05d98910d835b503e7be3d2e4071956f66fbbbc4
+ cp ../update.sh ubuntu/scripts/
+ wget https://releases.hashicorp.com/packer/1.1.2/packer_1.1.2_linux_amd64.zip
+ unzip packer_1.1.2_linux_amd64.zip
+ cd ubuntu
+ sed -i 's/"disk_size": "40960"/"disk_size": "409600"/' ubuntu-16.04-amd64.json
+}
+
+build_virtualbox() {
+ cd $DIR/bento/ubuntu
+ rm -rf ~/'VirtualBox VMs'/ubuntu-16.04-amd64
+ ../packer build -var 'headless=true' -only=virtualbox-iso ubuntu-16.04-amd64.json
+ vagrant box remove -f opnfv/container4nfv --all || true
+ vagrant box add opnfv/container4nfv ../builds/ubuntu-16.04.virtualbox.box
+}
+
+build_kvmbox() {
+ cd $DIR/bento/ubuntu
+ ../packer build -var 'headless=true' -only=qemu ubuntu-16.04-amd64.json
+ vagrant box remove -f opnfv/container4nfv.kvm --all || true
+ vagrant box add opnfv/container4nfv.kvm ../builds/ubuntu-16.04.libvirt.box
+}
+
+install_packages
+install_box_builder
+build_virtualbox
+build_kvmbox
diff --git a/src/vagrant/update.sh b/src/vagrant/update.sh
new file mode 100644
index 0000000..18752b9
--- /dev/null
+++ b/src/vagrant/update.sh
@@ -0,0 +1,58 @@
+#!/bin/sh -eux
+export DEBIAN_FRONTEND=noninteractive
+
+ubuntu_version="`lsb_release -r | awk '{print $2}'`";
+ubuntu_major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
+
+# Disable release-upgrades
+sed -i.bak 's/^Prompt=.*$/Prompt=never/' /etc/update-manager/release-upgrades;
+
+# Update the package list
+apt-get -y update;
+
+# update package index on boot
+cat <<EOF >/etc/init/refresh-apt.conf;
+description "update package index"
+start on networking
+task
+exec /usr/bin/apt-get update
+EOF
+
+# Disable periodic activities of apt
+cat <<EOF >/etc/apt/apt.conf.d/10disable-periodic;
+APT::Periodic::Enable "0";
+EOF
+
+# Upgrade all installed packages incl. kernel and kernel headers
+apt-get -y dist-upgrade -o Dpkg::Options::="--force-confnew";
+
+apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
+apt-key adv -k 58118E89F3A912897C070ADBF76221572C52609D
+cat << EOF | tee /etc/apt/sources.list.d/docker.list
+deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main
+EOF
+
+curl -s http://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
+cat <<EOF | tee /etc/apt/sources.list.d/kubernetes.list
+deb http://apt.kubernetes.io/ kubernetes-xenial main
+EOF
+apt-get update
+apt-get install -y --allow-downgrades docker-engine=1.12.6-0~ubuntu-xenial kubelet=1.7.0-00 kubeadm=1.7.0-00 kubectl=1.7.0-00 kubernetes-cni=0.5.1-00
+
+docker pull gcr.io/google_containers/kube-proxy-amd64:v1.7.10
+docker pull gcr.io/google_containers/kube-apiserver-amd64:v1.7.10
+docker pull gcr.io/google_containers/kube-controller-manager-amd64:v1.7.10
+docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.7.10
+docker pull gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.4
+docker pull gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.4
+docker pull gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.4
+docker pull gcr.io/google_containers/etcd-amd64:3.0.17
+docker pull gcr.io/google_containers/pause-amd64:3.0
+docker pull ubuntu:16.04
+docker pull nginx:1.13.6
+docker pull busybox:1.27.2
+docker pull weaveworks/weave-npc:2.0.5
+docker pull weaveworks/weave-kube:2.0.5
+docker pull quay.io/coreos/flannel:v0.9.0-amd64
+docker pull quay.io/calico/cni:v1.8.0
+docker pull quay.io/calico/node:v1.1.3