Vagrant Box for demo purposes using OpenShift Origin
Clone or download
Pull request Compare This branch is 3 commits ahead, 48 commits behind openshift-evangelists:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
release
scripts
utils
.gitignore
1_1_0_1.env.sample
README.asc
Vagrantfile
troubleshooting.asciidoc

README.asc

OpenShift Origin Vagrant latest

This repository let’s you test using Vagrant a latest branch of an OpenShift Origin install

PRE-REQUISITES

For this to work you need only 3 things:

  • Vagrant 1.7.2+

  • Fedora 23+ Base box

  • An internet connection

You can add the base box manually, or it will be pulled down first time you run vagrant up:

$ vagrant box add --name fedora/23-cloud-base https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box
$ vagrant box add --name fedora/23-cloud-base https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-libvirt.box

It works with LibVirt and VirtualBox as there is default fedora images for both.

Note
Windows users might need to install VC++ 2010 as reported in Vagrant.

USAGE

For testing the latest Origin code, just do:

vagrant up

It will add a:

  • Router

  • Registry

  • A user called admin as the cluster-admin

  • Origin Centos ImageStreams and templates

SCRIPTS

The installation and configuration process consists of 4 scripts:

  • os-setup.sh: This installs all required packages

  • docker-setup.sh: This will configure docker to work properly with Red Hat’s registry

  • origin-setup.sh: This is the most important of them all, it will clone the Origin’s GitHub repo (from openshift or somebody’s and master or a branch), it will build the code and install and configure Origin.

  • addons-setup.sh: It will allow you to install additional capabilities for working on OpenShift Origin (like, metrics, pulling downs images, xPaaS Image streams and templates, additional users,…​)

The execution of the provisioning scripts will happen just once (except for building and configuring Origin) unless forced. It will create a file names <TESTS_DIR>/<SCRIPT_FILENAME>.<FUNCTION>.configured that can be deleted in order to rerun the script.

You can use a ENV (FORCE_DOCKER) with anyvalue that will force installing whatever addon you have selected

  • FORCE_OS

  • FORCE_DOCKER

  • FORCE_ADDONS

Just set any value to this ENV to work.

DIRS

Default dirs used in the image:

  • BUILD_DIR: /go/src/github.com/openshift

  • CONFIG_DIR: /var/lib/origin

  • TESTS_DIR: /var/lib/origin/tests

  • BIN_DIR: /var/lib/origin/bin

CUSTOMIZATION

If you want to customize the behaviour, you can use some Environment variables, to create the environment or re-provision the environment:

  • ORIGIN_REPO: The repository where the fork is located, typically your user name, or a user name of somebody who’s fork you wanna try. (jorgemoralespou,yourname,…​). (openshift by default)

  • ORIGIN_BRANCH: The branch you want to test. (master by default)

  • ORIGIN_VM_IP: The IP of the VM. (10.2.2.2 by default)

  • ORIGIN_VM_DOMAIN: Domain used by the applications (apps.10.2.2.2.xip.io by default)

  • ORIGIN_VM_MEM: Memory used in the VM (4092 by default)

  • ACTION: What do you want to do if doing a re-provisioning of the Box. (none, clean, build, config).

    • clean: Will delete the origin repo and the openshift install and pull down again the configured git repo, build origin, and configure it.

    • build: Will delete the openshift install and update current origin repo from GitHub, build origin, and configure it.

    • configure: With the Origin instance you have built, just recreate the installation and configuration.

  • CONFIG: What do you want to do if doing a re-provisioning of the Box. ()

    • testusers: Add addtional users (for test)

    • originimages: Pull down origin images

    • centosimages: Pull down CentOS7 images

    • rhelimages: Pull down RHEL7 images

    • xpaasimages: Pull down xPaaS images

    • otherimages: Pull down aditional images as examples

    • osetemplates: Install OSE templates and imagestreams (default)

    • metrics: Install Hawkular metrics (default)

  • FORCE_OS

  • FORCE_DOCKER

  • FORCE_ADDONS

  • BUILD_IMAGES: Whether to build Origin images as part of the build, or use latest publishes images (true|false). Building images takes a lot of time (>15 minutes).

You can of course do it on creation time:

ORIGIN_REPO=spadgett ORIGIN_BRANCH=route-named-ports vagrant up

Or a later provisioning:

ORIGIN_REPO=openshift ORIGIN_BRANCH=master ACTION=clean vagrant provision

Or just pull down some dokerimages:

CONFIG=osetemplates,rhelimages,xpaasimages vagrant provision

You do not need to get into the box, as the default user is a cluster admin.

CUSTOMIZATION USING .env FILES

You can add all your customizations to an environment file .env and source the file just before doing any of the Vagrant commands. In these file you can export all the environment variables specific for your use case, and of course you can have multiple environment files and just source the one you want just before the Vagrant command.

There is a sample environment file that will build a Origin VM from a v1.1.0.1 tag and will add some additional images to the VM. You can just copy this file, and modify/add content to it.

cp 1_1_0_1.env.sample 1_1_0_1.env

And then run Vagrant with your environmental configruation.

source 1_1_0_1.env
vagrant up --provider virtualbox

USERS

Any user with any password will login as a regular user. If you want to access as an admin user, you need to use admin as the username.

RUNNING IMAGES

This VM is meant for development purposes, so it’s allowed to run any image as anyuid, allowing to run images made to run as root.

Exporting the VM

If you want to export your image for others to use, you can do so via:

vagrant package --base origin --output openshift3-1.1.1.box

And then, you need to import the .box file, and use it with a new Vagrantfile.

$ vagrant box add -n openshift3 openshift3-1.1.1.box

Use this minimum Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.7.2"

Vagrant.configure(2) do |config|

   config.vm.box = "openshift3"
   config.vm.network "private_network", ip: "10.2.2.2"
   config.vm.synced_folder ".", "/vagrant", disabled: true
   config.vm.hostname = "origin"

   config.vm.provider "virtualbox" do |vb|
      vb.memory = "4096"
      vb.cpus = 2
      vb.name = "origin-1.1.1"
   end
end

And then just Vagrant up you new environment

$ vagrant up
$ vagrant up --provider virtualbox

NFS mounts available in the VM

The VM will ship with 10 NFS mounts available at /nfsvolumes/pv{01..10}

All mounts have a corresponding PV created with ReadWriteOnce and ReadWriteMany capabilities and Recycle policy, and with a capacity of 10Gi.

If a user wants to create their own PV, he’ll need to edit or delete/recreate an unused PV.

Look at scripts in example nfs PVs or just create it with the following yaml as example

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv10
spec:
  capacity:
    storage: 256Mi
  accessModes:
    - ReadWriteOnce
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    server: localhost
    path: /nfsvolumes/pv10

VMs Docker Registry

OpenShift internal registry is exposed and available at hub.10.2.2.2.xip.io but it’s not secured. To access the registry you need to add it to the list of insecure registries for your docker daemon and reload the daemon. Then you’ll be able to pull/push images to the registry.

See details here