Skip to content

Instantly share code, notes, and snippets.

@allomov

allomov/README.md

Last active Aug 29, 2015
Embed
What would you like to do?

Description

This scripts provide the way to convert your instance (or image) to BOSH stemcell (containing MicroBOSH release).

What you'll need

  1. A running instance that you want to convert to stemcell (it should run Ubuntu or CentOS with default package repositories).
  2. VMware OVF tool with version 3.0.
  3. Some Ubuntu host to run script that will generate stemcell.

Steps

  1. Create "base os image" using create-base-os-image.sh script.
  2. Access to system that will be used generate BOSH stemcell (it can be instance in vsphere, your own machine, virtualbox machine).
  3. Install ovf tool v3.0.1. There are two ways to do it:
    • get file VMware-ovftool-3.0.1-XXXXX-lin.x86_64.bundle from VMware site or trusted source and run sudo /bin/sh VMware-ovftool-3.0.1-XXXXX-lin.x86_64.bundle
    • unpack archive with ovftool to /usr/lib/vmware-ovftool and make a link ln -s /usr/lib/vmware-ovftool/ovftool /usr/bin
  4. Run create-custom-stemcell.sh script to get stemcell.
# install pre-requirements
sudo apt-get update
sudo apt-get install -y git kpartx debootstrap qemu \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \
ruby1.9.1 ruby1.9.1-dev \
build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev \
libmysqlclient-dev libpq-dev libsqlite3-dev \
linux-headers-3.13.0-35 linux-headers-3.13.0-35-generic \
linux-image-3.13.0-35-generic linux-image-extra-3.13.0-35-generic \
grub adduser apt apt-utils bzip2 ca-certificates console-setup \
dash debconf eject gnupg ifupdown initramfs-tools iproute2 \
iputils-ping isc-dhcp-client kbd less locales \
lsb-release makedev mawk module-init-tools net-tools \
netbase netcat-openbsd ntpdate passwd procps sudo \
tzdata ubuntu-keyring udev ureadahead vim-tiny whiptail \
libssl-dev lsof strace bind9-host dnsutils tcpdump iputils-arping \
curl wget libcurl3 libcurl4-openssl-dev bison libreadline6-dev \
libxml2 libxml2-dev libxslt1.1 libxslt1-dev zip unzip nfs-common \
flex psmisc apparmor-utils iptables sysstat rsync openssh-server \
traceroute libncurses5-dev quota libaio1 gdb tripwire libcap2-bin \
libcap-dev libbz2-dev cmake scsitools mg htop module-assistant \
debhelper runit sudo uuid-dev libgcrypt11-dev \
kpartx
# This is how you can convert your instance to "base os image"
base_os_image_path=$HOME/base_os_image.tgz
sudo tar -cvpf $base_os_image_path --directory=/ --exclude=proc --exclude=sys --exclude=dev/!(null) --exclude=tmp --exclude=$base_os_image_path .
# base_os_image_path "base os image" generated in previous step
base_os_image_path=$HOME/base_os_image.tgz
# install pre-requirements
sudo apt-get update
sudo apt-get install -y git kpartx debootstrap qemu \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \
ruby1.9.1 ruby1.9.1-dev \
build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev \
libmysqlclient-dev libpq-dev libsqlite3-dev \
sudo gem install bundler
sudo mkdir -p /mnt/stemcells
sudo chown <username> /mnt/stemcells # <username> belongs to user you use to build stemcell
# install bosh
cd ~
git clone -b develop --single-branch https://github.com/cloudfoundry/bosh.git bosh # we use develop branch here to get the latest updates
cd bosh
git submodule foreach --recursive 'git submodule sync; git clean -d --force --force'
git submodule update --init --recursive --force
bundle install
# install ovf tool v3.0 (v3.0 is strict requirement, other versions will fail)
# vi ~/bosh/stemcell_builder/etc/settings.bash
# set ubuntu version (base_debootstrap_suite) to trusty
# set ovftool location (image_ovftool_path) to /usr/bin/ovftool (of course you need ovf tool to be installed)
# set stemcell_name and stemcell_version (they should differ of what you already have)
cd ~/bosh
# ! $base_os_image_path should be full path (without using ~)
bundle exec rake stemcell:build_os_image[ubuntu,trusty,$base_os_image_path]
bundle exec rake stemcell:build_with_local_os_image[vsphere,ubuntu,trusty,go,$base_os_image_path]
# in the end you'll find stemcell in ~/bosh/tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment