Skip to content

openshift-evangelists/vagrant-origin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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+

  • Centos 7+ Base box

  • An internet connection

The base box will be pulled down first time you run vagrant up:

It works with LibVirt and VirtualBox as there is default centos 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 5 scripts:

  • scripts/install.sh: This is the main install process. Will use configuration located in config/config.env to configure the VM and can be executed at any time from within the VM to change configuration.

  • scripts/base/os-setup: This installs all required packages

  • scripts/base/docker-setup: This will configure docker to work properly.

  • scripts/base/origin-setup: 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.

  • scripts/base/addons-setup: 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 or modify config/config.env, to create the environment or re-provision the environment:

For the generated VM (This Environment will be set on your host):

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

For the installation (This configuration will be in the VM or in config/config.env)

  • __OS_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)

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

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

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

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

    • none: normal behavior

    • 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.

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

    • release: Will use a release published in github to install, and not building from source code

  • __OS_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

    • xpaastemplates: Install xPaaS templates and imagestreams (default)

    • metrics: Install Hawkular metrics (default)

    • logging: Install EFK logging (default)

  • __OS_FORCE_OS

  • __OS_FORCE_DOCKER

  • __OS_FORCE_ADDONS

  • __OS_ONLY_BUILD_PLATFORMS: List of platforms to run cross builds or empty list to build for all (defaults: linux/amd64). Available platforms:

    • linux/amd64

    • darwin/amd64

    • windows/amd64

    • linux/386

  • __OS_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).

  • OS_IMAGES_VERSION: Version of images to use if not building them. Should be aligned with OS_ORIGIN_BRANCH for Origin releases.

  • __OS_JOURNAL_SIZE: Size to provide to system journal (defaults: 100M). Use M,G to qualify the size.

  • __OS_DOCKER_VERSION: Version of docker package to be installed or empty string to install latest available version (default: ""). If using Openshift branch/release v1.3.0-alpha.2 or older then the docker version "1.9.1-25.el7.centos" must be installed.

  • __OS_DOCKER_STORAGE_SIZE: Size to provide for Docker filesystem. (defaults: 30G). Use G to qualify size in Gigabytes.

  • __OS_PV_COUNT: Total count of persistent volumes. (defaults: 10).

  • __OS_PV_SIZE: Persistent volume size in Gi. (defaults: 10).

  • __OS_PV_NFS_OPTIONS: NFS mounts options used for the persistent volumes. (defaults: rw,root_squash).

You can of course do it on creation time:

echo "export __OS_ORIGIN_REPO=spadgett" > config/config.env
echo "export __ORIGIN_BRANCH=route-named-ports" >> config/config.env
vagrant up

Or a later provisioning:

vagrant ssh
sudo -i
echo "export __OS_ORIGIN_REPO=spadgett" > /config/config.env
echo "export __OS_ORIGIN_BRANCH=route-named-ports" >> /config/config.env
echo "export __OS_ACTION=clean" >> /config/config.env
/scripts/install.sh

CUSTOMIZATION USING .env FILES

You can add all your customizations to an environment file config/config.env before you create the VM with vagrant up command.

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. This user has cluster-admin role.

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.

NFS mounts available in the VM

The VM will ship by default with 10 NFS mounts in mode rw,root_squash available at /nfsvolumes/pv{01..10}.

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

If a user wants to create their own PV there’s a script that can be run in the VM to do so (as root):

/scripts/nfs/create-nfs-volume <VOLUME_NAME> [<VOLUME_SIZE> [<NFS_OPTIONS>]]

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

Metrics

The VM can be installed with metrics framework installed. If you don’t want to use it, there’s 2 scripts to enable/disable them, that can be run by any logged in user in the VM.

To enable metrics:

vagrant ssh
oc login -u user    # This step is only required if there's no user logged in
enable-metrics

To disable metrics:

vagrant ssh
oc login -u user  # This step is only required if there's no user logged in
disable-metrics
Note
You’ll need to access the hawkular endpoint and accept it’s self signed certificate to see metrics in the pods

Metrics Configuration

By default, metrics will be installed in the openshift-infra project and accesible at: https://hawkular-metrics.apps.10.2.2.2.xip.io/

Logging

The VM can be installed with logging framework installed. If you don’t want to use it, there’s 2 scripts to enable/disable them, that can be run by any logged in user in the VM.

To enable logging:

vagrant ssh
oc login -u user    # This step is only required if there's no user logged in
enable-logging

To disable logging:

vagrant ssh
oc login -u user  # This step is only required if there's no user logged in
disable-logging

Logging Configuration

By default, logging will be installed in the openshift-infra project and accesible at: https://kibana.apps.10.2.2.2.xip.io/

Cockpit

The VM will be installed with cockpit for OpenShift in it’s own project. You can access cockpit’s console at http://cockpit.apps.10.2.2.2.xip.io/. Use admin user as most of the functionalities require a cluster-admin to be executed.

Exporting the VM

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

vagrant package --base origin --output openshift-origin-1.2.0.box

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

$ vagrant box add -n openshift-origin openshift-origin-1.2.0.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 = "openshift-origin"
   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 = "openshift-origin"
   end
end

And then just Vagrant up you new environment

$ vagrant up
$ vagrant up --provider virtualbox

Scripted packaging

There is some scripts to help package the VM in release/