Adding vagrant configs to kuryr-kubernetes

Implements: blueprint vagrant-kuryr-k8s
Change-Id: I33667d158cd43b2c86264a5267af9fb997c42868
This commit is contained in:
Frederick F. Kautz IV 2017-03-13 20:03:19 +00:00
parent 3ea54ef501
commit a980668a9b
5 changed files with 203 additions and 0 deletions

66
contrib/vagrant/README.md Normal file
View File

@ -0,0 +1,66 @@
vagrant-devstack-Kuryr-Kubernetes
=================================
Getting started
---------------
A Vagrant based kuryr,neutron,keystone,docker and kubernetes system.
Steps to try vagrant image:
1. Install Vagrant on your local machine. Install one of the current
providers supported: VirtualBox, Libvirt or Vagrant
2. Git clone kuryr-kubernetes repository.
3. Run `cd kuryr-kubernetes/contrib/vagrant`
4. Run `vagrant up`
It will take from 10 to 60 minutes, depending on your internet speed.
Vagrant-cachier can speed up the process [2].
5. `vagrant ssh`
At this point you should have experimental kubernetes (etcdv3, k8s-apiserver,
k8s-controller-manager, k8s-scheduler, kubelet and kuryr-controller), docker,
kuryr, neutron, keystone all up, running and pointing to each other. Pods and
services orchestrated by kubernetes will be backed by kuryr+neutron. The
architecture of the setup can be seen at [1].
References:
[1] https://docs.openstack.org/developer/kuryr-kubernetes/devref/kuryr_kubernetes_design.html
[2] http://fgrehm.viewdocs.io/vagrant-cachier/
Vagrant Options available
-------------------------
You can set the following environment variables before running `vagrant up` to modify
the definition of the Virtual Machine spawned:
* **VAGRANT\_KURYR\_VM\_BOX**: To change the Vagrant Box used. Should be available in
[atlas](http://atlas.hashicorp.com).
export VAGRANT_KURYR_VM_BOX=centos/7
Could be an example of a rpm-based option.
* **VAGRANT\_KURYR\_VM\_MEMORY**: To modify the RAM of the VM. Defaulted to: 4096
* **VAGRANT\_KURYR\_VM\_CPU**: To modify the cpus of the VM. Defaulted to: 2
* **VAGRANT\_KURYR\_RUN\_DEVSTACK**: Whether `vagrant up` should run devstack to
have an environment ready to use. Set it to 'false' if you want to edit
`local.conf` before run ./stack.sh manually in the VM. Defaulted to: true.
See below for additional options for editing local.conf.
Additional devstack configuration
---------------------------------
To add additional configuration to local.conf before the VM is provisioned, you can
create a file called "user_local.conf" in the contrib/vagrant directory of
networking-kuryr. This file will be appended to the "local.conf" created during the
Vagrant provisioning.
For example, to use OVN as the Neutron plugin with Kuryr, you can create a
"user_local.conf" with the following configuration:
enable_plugin networking-ovn http://git.openstack.org/openstack/networking-ovn
enable_service ovn-northd
enable_service ovn-controller
disable_service q-agt
disable_service q-l3
disable_service q-dhcp

49
contrib/vagrant/Vagrantfile vendored Normal file
View File

@ -0,0 +1,49 @@
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
VM_MEMORY = ENV.fetch('VAGRANT_KURYR_VM_MEMORY', 6144).to_i
VM_CPUS = ENV.fetch('VAGRANT_KURYR_VM_CPUS', 2).to_i
RUN_DEVSTACK = ENV.fetch('VAGRANT_KURYR_RUN_DEVSTACK', 'true')
config.vm.hostname = 'devstack'
config.vm.provider 'virtualbox' do |v, override|
override.vm.box = ENV.fetch('VAGRANT_KURYR_VM_BOX', 'ubuntu/xenial64')
v.memory = VM_MEMORY
v.cpus = VM_CPUS
end
config.vm.provider 'parallels' do |v, override|
override.vm.box = ENV.fetch('VAGRANT_KURYR_VM_BOX', 'boxcutter/ubuntu1404')
v.memory = VM_MEMORY
v.cpus = VM_CPUS
v.customize ['set', :id, '--nested-virt', 'on']
end
config.vm.provider 'libvirt' do |v, override|
override.vm.box = ENV.fetch('VAGRANT_KURYR_VM_BOX', 'yk0/ubuntu-xenial')
v.memory = VM_MEMORY
v.cpus = VM_CPUS
v.nested = true
v.graphics_type = 'spice'
v.video_type = 'qxl'
end
config.vm.synced_folder '../../devstack/', '/devstack', type: 'rsync'
# For CentOS machines it needs to be specified
config.vm.synced_folder '.', '/vagrant', type: 'rsync'
config.vm.provision :shell do |s|
s.path = 'vagrant.sh'
s.args = RUN_DEVSTACK
end
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.scope = :box
end
config.vm.network :forwarded_port, guest: 80, host_ip: "127.0.0.1", host: 8080
end

View File

@ -0,0 +1,5 @@
export SERVICE_USER=admin
export SERVICE_PASSWORD=pass
export SERVICE_TENANT_NAME=admin
export SERVICE_TOKEN=pass
export IDENTITY_URL=http://127.0.0.1:5000/v2.0

62
contrib/vagrant/devstack.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
set -ex
echo $(whoami)
BASHPATH=$(dirname "$0"\")
RUN_DEVSTACK="$1"
echo "Run script from $BASHPATH"
# Copied shamelessly from Devstack
function GetOSVersion {
if [[ -x $(which lsb_release 2>/dev/null) ]]; then
os_FAMILY='Debian'
elif [[ -r /etc/redhat-release ]]; then
os_FAMILY='RedHat'
else
echo "Unsupported distribution!"
exit 1;
fi
}
GetOSVersion
if [[ "$os_FAMILY" == "Debian" ]]; then
export DEBIAN_FRONTEND noninteractive
sudo apt-get update
sudo apt-get install -qqy git
elif [[ "$os_FAMILY" == "RedHat" ]]; then
sudo yum install -y -d 0 -e 0 git
fi
# determine checkout folder
PWD=$(getent passwd $OS_USER | cut -d: -f6)
DEVSTACK=$PWD/devstack
# check if devstack is already there
if [[ ! -d "$DEVSTACK" ]]
then
echo "Download devstack into $DEVSTACK"
# clone devstack
su "$OS_USER" -c "cd && git clone -b master https://github.com/openstack-dev/devstack.git $DEVSTACK"
echo "Copy configuration"
# copy local.conf.sample settings (source: kuryr/devstack/local.conf.sample)
cp /devstack/local.conf.sample $DEVSTACK/local.conf
# If local settings are present, append them
if [ -f "/vagrant/user_local.conf" ]; then
cat /vagrant/user_local.conf >> $DEVSTACK/local.conf
fi
chown "$OS_USER":"$OS_USER" "$DEVSTACK"/local.conf
fi
if $RUN_DEVSTACK; then
echo "Start Devstack"
su "$OS_USER" -c "cd $DEVSTACK && ./stack.sh"
else
echo "Virtual Machine ready. You can run devstack by executing '/home/$OS_USER/devstack/stack.sh'"
fi

21
contrib/vagrant/vagrant.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
getent passwd vagrant > /dev/null
if [ $? -eq 0 ]; then
export OS_USER=vagrant
else
getent passwd ubuntu > /dev/null
if [ $? -eq 0 ]; then
export OS_USER=ubuntu
fi
fi
set -ex
export HOST_IP=127.0.0.1
# run script
bash /vagrant/devstack.sh "$1"
#set environment variables for kuryr
su "$OS_USER" -c "echo 'source /$OS_USER/config/kuryr_rc' >> ~/.bash_profile"