Initial helm and kubectl support for Vagrant dev env

This commit is contained in:
Pete Birley 2017-03-26 11:09:05 -05:00
parent bc5264df05
commit 1b1658a1ff
5 changed files with 96 additions and 28 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@
.idea/
**/_partials.tpl
**/_globals.tpl
dev/.vagrant
dev/*.log

43
dev/README.md Normal file
View File

@ -0,0 +1,43 @@
# Development Environment Setup
## Requirements
* Hardware
* 16GB RAM
* 32GB HDD Space
* Software
* Vagrant
* VirtualBox
* Kubectl
* Helm
* Git
## Deploy
* Make sure you are in the directory containing the Vagrantfile before running the following commands.
### Create VM
``` bash
vagrant up --provider virtualbox
```
### Deploy NFS Provisioner for development PVCs
``` bash
vagrant ssh --command "sudo docker exec kubeadm-aio kubectl create -R -f /opt/nfs-provisioner/"
```
### Setup Clients and deploy Helm's tiller
``` bash
./setup-dev-host.sh
```
### Label VM node(s) for OpenStack-Helm Deployment
``` bash
kubectl label nodes openstack-control-plane=enabled --all --namespace=openstack
kubectl label nodes openvswitch=enabled --all --namespace=openstack
kubectl label nodes openstack-compute-node=enabled --all --namespace=openstack
```

56
dev/Vagrantfile vendored
View File

@ -1,5 +1,14 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# NOTE: Variable overrides are in ./config.rb
require "yaml"
require "fileutils"
# Use a variable file for overrides:
CONFIG = File.expand_path("config.rb")
if File.exist?(CONFIG)
require CONFIG
end
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
@ -19,52 +28,44 @@ Vagrant.configure("2") do |config|
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 6443, host: 8443
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
config.vm.network "private_network", ip: "192.168.33.10"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.synced_folder "../", "/opt/openstack-helm"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "8192"
vb.memory = $ram
# Customize the number of vCPUs in the VM:
vb.cpus = $vcpu_cores
# Set the size of the VM's root disk:
unless File.exist?('.vagrant/machines/default/virtualbox/openstack-helm-storage.vdi')
vb.customize ['createhd', '--filename', '.vagrant/machines/default/virtualbox/openstack-helm-storage', '--size', $docker_disk]
end
#
# View the documentation for the provider you are using for more
# information on available options.
vb.customize ['storageattach', :id, '--storagectl', 'SCSI', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', '.vagrant/machines/default/virtualbox/openstack-helm-storage.vdi']
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# Enable provisioning with a shell script.
config.vm.provision "shell", inline: <<-SHELL
# Setup docker storage
mkfs.xfs /dev/disk/by-path/pci-0000\:00\:14.0-scsi-0\:0\:2\:0 -f -L docker-srg
mkdir -p /var/lib/docker
echo "LABEL=docker-srg /var/lib/docker xfs defaults 0 0" >> /etc/fstab
mount -a
apt-get update
apt-get install -y \
docker.io \
@ -85,6 +86,7 @@ Vagrant.configure("2") do |config|
--volume=/etc/kubernetes:/etc/kubernetes:rw \
--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro \
--volume=/var/run/docker.sock:/run/docker.sock \
--env KUBE_BIND_DEV=enp0s8 \
--env KUBELET_CONTAINER=docker.io/port/kubeadm-aio:latest \
docker.io/port/kubeadm-aio:latest
SHELL

4
dev/config.rb Normal file
View File

@ -0,0 +1,4 @@
# VM Specs
$docker_disk = 20480
$vcpu_cores = 4
$ram = 8192

17
dev/setup-dev-host.sh Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e
# Setting up kubectl creds
mkdir -p ${HOME}/.kube
if [ -f ${HOME}/.kube/config ]; then
echo "Previous kube config found, backing it up"
mv -v ${HOME}/.kube/config ${HOME}/.kube/config.$(date "+%F-%T")
fi
echo "Getting kubeconfig from kube1"
vagrant ssh default -c "sudo cat /etc/kubernetes/admin.conf" > ${HOME}/.kube/config
# Setting up helm client if present
if which helm 2>/dev/null; then
helm init
fi
echo "clients should now be ready to access the Kubernetes cluster"