Skip to content

Building a TopStack Base Image

Jimmy Jarrett edited this page Feb 25, 2014 · 5 revisions

TopStack starts with a base image that is obtained from the OpenStack Cloud it's to be deployed into. The base Image is used to create VMs in which TopStack will configure and install components as necessary to build services in the Cloud. TopStack starts from an image with some installed components to speed up instance startup as installs from scratch on every launch would take too long to deploy.

Note: If you run into errors with the commands below, try using sudo before the command.

Examples below were done by launching an Ubuntu 12.04 VM from an Ubuntu Image from an OpenStack Cloud. Perform the steps described below in order to configure the TopStack Base Image.

1. Install NTP

apt-get -qq install ntp

2. Install a chef client

The sample below configures the client with "localhost" as a chef host. The server URL doesn't matter; TopStack will inject the current configuration when an instance is launched.

echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
mkdir -p /etc/apt/trusted.gpg.d
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
gpg --export [email protected] | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null

apt-get -qq update

apt-get -qq upgrade

apt-get -qq install opscode-keyring

echo "chef chef/chef_server_url string http://127.0.0.1:4000" | debconf-set-selections
apt-get -qq install chef

3. Install the TopStack Message Agent (to enable monitoring)

This will require a binary to built from the message agent project (See the build instructions).

mkdir -p /var/lib/topstack
tar -zxvf ${TOPSTACK_DIR}/TopStackMessageAgent/build/transcend-agent.tar.gz -C /var/lib/topstack
cp /var/lib/topstack/collectd/etc/init/transcend-agent.conf /etc/init
initctl reload-configuration

4. Add an init script to instance startup.

cat <<-EOC > /etc/rc.local
#!/bin/sh -e
#
# rc.local for TopStack
#
# Get the user ssh key using the meta-data service
mkdir -p /root/.ssh
echo >> /root/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> /root/.ssh/authorized_keys
echo "AUTHORIZED_KEYS:"
echo "************************"
cat /root/.ssh/authorized_keys
echo "************************"

# Bootstrap basic instance data
curl -m 10 -s http://169.254.169.254/latest/user-data >> /root/bootstrap.sh
if [ -f /root/bootstrap.sh ]; then
     /bin/chmod +x /root/bootstrap.sh
     /root/bootstrap.sh
     /bin/rm -f /root/bootstrap.sh
fi

exit 0
EOC
chmod +x /etc/rc.local

That's it! At this point the VM is ready to have an Image created from it and uploaded into the OpenStack Cloud.