From 3b6c509e5f26f5719c3823162d6b8e1d08a43858 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Tue, 5 May 2015 13:34:04 -0600 Subject: [PATCH] Push initial version of files for `rkt` Push an initial Vagrantfile, external YAML data file, shell script, and README.md for an environment that can be used to experiment with `rkt`. --- rkt/README.md | 19 +++++++++++++++++++ rkt/Vagrantfile | 42 ++++++++++++++++++++++++++++++++++++++++++ rkt/servers.yml | 5 +++++ rkt/setup.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 rkt/README.md create mode 100644 rkt/Vagrantfile create mode 100644 rkt/servers.yml create mode 100755 rkt/setup.sh diff --git a/rkt/README.md b/rkt/README.md new file mode 100644 index 0000000..d5906d2 --- /dev/null +++ b/rkt/README.md @@ -0,0 +1,19 @@ +# Running Containers with rkt + +These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) quickly and relatively easily experiment with using `rkt` (pronounced "rock-it"), the CoreOS implementation of the App Container (appc) specification. The configuration was tested using Vagrant 1.7.2, VMware Fusion 6.0.5, and the Vagrant VMware plugin. + +## Contents + +* **README.md**: This file you're currently reading. + +* **servers.yml**: This YAML file contains a list of VM definitions and associated configuration data. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. No changes should be necessary to use this file. + +* **setup.sh**: This shell script is called by the Vagrant shell provisioner and configures `rkt` inside the VM created by Vagrant. No changes should be needed to this file. + +* **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file. + +## Instructions + +These instructions assume you've already installed VMware Fusion, Vagrant, and the Vagrant VMware plugin. Please refer to the documentation for those products for more information on installation or configuration. + +**[NOT YET COMPLETE]** diff --git a/rkt/Vagrantfile b/rkt/Vagrantfile new file mode 100644 index 0000000..179fd3e --- /dev/null +++ b/rkt/Vagrantfile @@ -0,0 +1,42 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Specify Vagrant version and Vagrant API version +Vagrant.require_version ">= 1.6.0" +VAGRANTFILE_API_VERSION = "2" + +# Require 'yaml' module +require 'yaml' + +# Read YAML file with VM details (box, CPU, and RAM) +servers = YAML.load_file('servers.yml') + +# Create and configure the VMs +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + # Always use Vagrant's default insecure key + config.ssh.insert_key = false + + # Iterate through entries in YAML file to create VMs + servers.each do |servers| + config.vm.define servers["name"] do |srv| + + # Don't check for box updates + srv.vm.box_check_update = false + srv.vm.hostname = servers["name"] + srv.vm.box = servers["box"] + + # Enable default synced folder + srv.vm.synced_folder ".", "/vagrant" + # Perform final provisioning activities + #srv.vm.provision "shell", path: "config.sh", privileged: true + #srv.vm.provision "file", source: "adminrc", destination: "/home/vagrant/adminrc" + + # Configure VMs with RAM and CPUs per settings in servers.yml + srv.vm.provider :vmware_fusion do |vmw| + vmw.vmx["memsize"] = servers["ram"] + vmw.vmx["numvcpus"] = servers["vcpu"] + end + end + end +end diff --git a/rkt/servers.yml b/rkt/servers.yml new file mode 100644 index 0000000..f356ff3 --- /dev/null +++ b/rkt/servers.yml @@ -0,0 +1,5 @@ +--- +- name: rocket-01 + box: slowe/ubuntu-trusty-x64 + ram: 512 + vcpu: 1 diff --git a/rkt/setup.sh b/rkt/setup.sh new file mode 100755 index 0000000..16945a4 --- /dev/null +++ b/rkt/setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Download rkt from GitHub +wget https://github.com/coreos/rkt/releases/download/v0.5.5/rkt-v0.5.5.tar.gz + +# Unpack the rkt files and move to final destination +tar xzvf rkt-v0.5.5.tar.gz +cd rkt-v0.5.5 +sudo mv rkt /usr/local/bin/ +sudo mv stage1.aci /usr/local/bin/ +rm -rf rkt-v0.5.5 + +# Create a rkt user and group +sudo useradd -M -d /var/lib/rkt -r -s /usr/bin/nologin rkt + +# Add default vagrant user to rkt group +sudo usermod -G rkt -a vagrant + +# Set up directories for rkt +sudo mkdir -p /var/lib/rkt +sudo chown -R root:rkt /var/lib/rkt +sudo chmod -R 0775 /var/lib/rkt +sudo chmod g+s /var/lib/rkt +sudo mkdir -p /etc/rkt +sudo chown -R root:rkt /etc/rkt +sudo chmod -R 0775 /etc/rkt +sudo chmod g+s /etc/rkt