Skip to content

Instantly share code, notes, and snippets.

@yudai
Last active December 18, 2015 19:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yudai/5832367 to your computer and use it in GitHub Desktop.
Save yudai/5832367 to your computer and use it in GitHub Desktop.

How to deploy CFv2 with OpenStack and BOSH on a single machine

Links

Requirements

  • Ubuntu 12.04 64bit server with 16GB RAM

Variables in This Document

  • eth0
    • The interface that has a public IP address
  • 192.168.10.10/24
    • The network that your server belongs to
  • 192.168.10.2
    • The IP address of your server

Installing OpenStack (DevStack)

The OpenStack team provides an easy installer named DevStack that builds an OpenStack instance on a single server.

Cloning the Repository and Checking out the stable branch

sudo apt-get install git
git clone git://github.com/openstack-dev/devstack.git
cd devstack

# Using Grizlly
git checkout -t origin/stable/grizzly

Configuration

You need some configuration to build a DevStack instance. The configuration file name is localrc.

(Modify the netowrk settings according to your own environemnent)

cat <<_EOF_ > localrc
# All passwords are 'openstack'
DATABASE_PASSWORD=openstack
RABBIT_PASSWORD=openstack
SERVICE_TOKEN=openstack
SERVICE_PASSWORD=openstack
ADMIN_PASSWORD=openstack

# Allow larger Ephemeral disks
VOLUME_BACKING_FILE_SIZE=70000M
# Allow faster API calls
API_RATE_LIMIT=False

# NIC connected to your network
PUBLIC_INTERFACE=eth0
# Public IP addresses to be bound to edge VMs such as routers and MicroBOSH.
# (Other VMs use the default private (10.0.0.0/24) network)
# At least 2 public IP addresses are qureied.
# 192.168.10.128 - 192.168.10.255
FLOATING_RANGE=192.168.10.128/25
# Your server IP address
HOST_IP=192.168.10.2
_EOF_

Note

  • Quantum (advanced network manager) is not required on this document.
  • When you change the value of VOLUME_BACKING_FILE_SIZE in the localrc, delete /opt/stack/data/stack-volumes-backing-file to apply the change.

Running the installer script

Run the command below:

./stack.sh

Creating a User and Project for BOSH

Open http://192.168.10.2 on your web browser. You will see the login page of the OpenStack console which is called Horizon. You can login to the console with the ID admin and the password openstack. Choose the Admin tab on the left menu and move to Users page. You can create users on this page. Click the "+ Create User" button on the upper left of the page and fill out the form. In this instruction, we use bosh_admin for the user name and c1oudc0w for the password. In the form, you can create a Project (sometimes also called Tenant) at the same time. Click the "+" button on the Project field and create a project named BOSH. And then, choose Admin at the Role filed.

Create Flavors for BOSH VMs

If you are an AWS user, you are familiar with flavors. Flavars on OpenStack are types of VM spec such as m1.micro, m1.medium and m1.large on the EC2. You need to create some flavors used later by bosh-bootstrap.

Before createing flavaors, you need to export some environemnt variables to connect to your devstack instance. Of course, you can write these commands to your .profle file.

export OS_USERNAME=bosh_admin
export OS_PASSWORD=c1oudc0w
export OS_TENANT_NAME=BOSH
export OS_AUTH_URL=http://192.168.10.2:5000/v2.0/ # found at 'Access & Securit' -> 'API Access'

And then, delete existing default flavors once for simplicity.

nova flavor-list | grep m1 | awk '{ print $4 }' | xargs -n 1 nova flavor-delete

Finally, create three flavors.

nova flavor-create m1.small 2 2048 20 1 --ephemeral 20 --rxtx-factor 1 --is-public true
nova flavor-create m1.medium 3 4096 20 2 --ephemeral 20 --rxtx-factor 1 --is-public true
nova flavor-create m1.microbosh 20 4096 20 2 --ephemeral 20 --rxtx-factor 1 --is-public true

Deploying a MicroBOSH with bosh-bootstrap

To bootstarap a BOSH system, we need to deploy a MicroBOSH first. MicroBOSH is a single VM that has all BOSH components. You can use bosh-bootstrap developed by Dr. NIC to deploy a MicroBOSH VM to your DevStack instance. bosh-bootstrap automatically setup SSH keypairs, secrity groups and other misc settings.

# Cloning the lateset source code from Github
git clone https://github.com/cloudfoundry-community/bosh-bootstrap.git
cd bosh-bootstrap
bundle install
bundle exec ./bin/bosh-bootstrap deploy
# Then you will be asked some questions:
1. AWS
2. OpenStack
Choose your infrastructure: 2

Using provider OpenStack

Username: bosh_admin
Password: c1oudc0w
Tenant: BOSH
Authorization Token URL: http://192.168.10.2:5000/v2.0
...

Deploying a Full BOSH, Not

A full BOSH system requires too much resources, so we skip deploying it.

Deploying the CF instance

Writing a Manifest for the CF Instance

TODO: detailed instruction

You can use Dr. Nic's sample manifest.

Configuring the Project for the CF Instance

Open the OpenStack console and configure the BOSH project for your CF instance.

Making RAM Space larger

The default memory quota is too small for a CF system. Set 9999999 to the RAM (MB) field in the form of Modify Quota box in the Project page.

Provisioning a Public Floating IP Address

You need to manually create a Floating IP Address for your router VM. Go to the Floating IPs page via the Access & Security tab in the left menu and create a Floating IP Address.

Creating a Security Group

TODO) Minumum port range

To open ports which are used by CF components, create a security group named cf. Then create a rule that opens ports from 1 to 65533.

Preparing cf-release

As usual, clone the cf-release repository and create a release.

gem install bosh_cli

cd ~
git clone https://github.com/cloudfoundry/cf-release.git
cd cf-release
./update
bosh create release --force

Downloading the latest stemcell

cd ~
mkdir stemcells
cd stemcells
wget http://bosh-jenkins-artifacts.s3.amazonaws.com/last_successful_bosh-stemcell-openstack.tgz

Deploying the CF instance

Good luck!

bosh upload release ~/cf-release/dev_releases/appcloud-131.1-dev.yml
bboh upload stemcell ~/stemcells/last_successful_bosh-stemcell-openstack.tgz
bosh deployment manifest.yml
bosh deploy

Trouble Shooting

Something wrong with DevStack

./unstack.sh and reboot the server.

Something wring with MicroBOSH

bundle exec ./bin/bosh-bootstrap delete and remove config files with rm -rf ~/.microbosh/settings.yml && rm -rf ~/.microbosh/deployments/bosh* and then re-deploy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment