Everett Toews | @etoews |
Dana Bauer | @geography76 |
Use the arrow keys to navigate
To give you the foundation of building and deploying an application on OpenStack and to give you the confidence to use tools of a higher level of abstraction in the future.
Do Something
"To produce the ubiquitous Open Source Cloud Computing platform that will meet the needs of public and private clouds regardless of size, by being simple to implement and massively scalable."
"To be recognized as one of the world's greatest service companies."
And more:
ssh root@my.deploy-server.ipv4.address
apt-get -y update; apt-get -y upgrade
apt-get -y install vim git jq
apt-get -y install python-dev python-pip libssl-dev libffi-dev
pip install virtualenv virtualenvwrapper
echo "export WORKON_HOME=$HOME/.virtualenvs" >> $HOME/.profile
echo "source /usr/local/bin/virtualenvwrapper.sh" >> $HOME/.profile
source $HOME/.profile
See: Virtual Environments
mkvirtualenv osc
pip install python-openstackclient==1.3.0
openstack --version
openstack complete > .osc.bash_completion
echo "source $HOME/.osc.bash_completion" >> $HOME/.profile
source $HOME/.profile
cat <<EOF > $HOME/os_env.rc
export OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
export OS_REGION_NAME=IAD
export OS_USERNAME=my-account-username
export OS_PROJECT_NAME=my-account-number
export OS_PASSWORD=my-account-password
EOF
echo "source $HOME/os_env.rc" >> $HOME/.profile
source $HOME/.profile
env | grep OS_
Note: Watch out for &s in the password.
workon osc
openstack image list
openstack --debug server list
openstack server list --format json
openstack keypair create $OS_USERNAME-qcon > $HOME/.ssh/id_rsa.qcon_deploy
chmod 400 $HOME/.ssh/id_rsa.qcon_deploy
git clone https://github.com/everett-toews/app-on-openstack.git
Note: Stateful
workon osc
pip install python-troveclient==1.2.0
trove --version
cat <<EOF >> $HOME/os_env.rc
export OS_TENANT_ID=$OS_PROJECT_NAME
export TROVE_SERVICE_TYPE=rax:database
EOF
source $HOME/.profile
more $HOME/os_env.rc
workon osc
trove flavor-list
trove create \
--size 2 \
--databases watermark \
--users wmadmin:password \
--datastore MySQL \
$OS_USERNAME-watermark 2
trove list 2>/dev/null | grep $OS_USERNAME
trove --json list 2>/dev/null | jq .
export WM_DB_HOSTNAME=$(trove --json list 2>/dev/null | \
jq -r '.[] | select(.name == "'"$OS_USERNAME-watermark"'").hostname')
echo $WM_DB_HOSTNAME
cat <<EOF > $HOME/db_env.rc
export WM_DB_ENGINE_DRIVER=mysql+pymysql
export WM_DB_USERNAME=wmadmin
export WM_DB_PASSWORD=password
export WM_DB_HOSTNAME=$WM_DB_HOSTNAME
export WM_DB_DATABASE=watermark
EOF
echo "source $HOME/db_env.rc" >> $HOME/.profile
source $HOME/.profile
env | grep WM_
mkvirtualenv api
pip install -r $HOME/app-on-openstack/code/api/requirements.txt
python $HOME/app-on-openstack/code/api/manage.py create_all
Note: Stateful
workon osc
openstack container create $OS_USERNAME-watermark
# Scroll to the bottom!
TOKEN=`curl -s -X POST https://identity.api.rackspacecloud.com/v2.0/tokens \
-d '{"auth": {"passwordCredentials": {"username":"'"$OS_USERNAME"'", "password":"'"$OS_PASSWORD"'"}}}' \
-H "Content-type: application/json" | \
jq -r .access.token.id`
CF_CDN_ENDPOINT=`curl -s -X POST https://identity.api.rackspacecloud.com/v2.0/tokens \
-d '{"auth": {"passwordCredentials": {"username":"'"$OS_USERNAME"'", \
"password":"'"$OS_PASSWORD"'"}}}' \
-H "Content-type: application/json" | \
jq -r '.access.serviceCatalog[] | select(.name == "cloudFilesCDN").endpoints[] | select(.region == "'"$OS_REGION_NAME"'").publicURL'`
WM_CONTAINER_CDN_URL=`curl -s -i -X PUT $CF_CDN_ENDPOINT/$OS_USERNAME-watermark \
-H "X-Auth-Token: $TOKEN" \
-H "X-Cdn-Enabled: True" |\
grep X-Cdn-Uri | \
awk '{print $2}'`
echo "export WM_CONTAINER_CDN_URL=$WM_CONTAINER_CDN_URL" >> $HOME/api_env.rc
more $HOME/api_env.rc
Note: Here you would use Swift's Container Read instead
Note: Stateful ("temporarily")
mkvirtualenv worker
pip install -r $HOME/app-on-openstack/code/worker/requirements.txt
$HOME/app-on-openstack/code/worker/deploy.py
Note: Stateless
workon osc
openstack image list
export IMAGE_NAME="Ubuntu 15.04 (Vivid Vervet) (PVHVM)"
echo 'export IMAGE_NAME="'$IMAGE_NAME'"' >> $HOME/.profile
openstack flavor list
export FLAVOR_ID=performance1-1
echo "export FLAVOR_ID=$FLAVOR_ID" >> $HOME/.profile
cat <<EOF >> $HOME/api_env.rc
export WM_CONFIG_ENV=testing
EOF
more $HOME/api_env.rc
openstack server create \
--image "$IMAGE_NAME" \
--flavor $FLAVOR_ID \
--key-name $OS_USERNAME-qcon \
--user-data $HOME/app-on-openstack/code/api/deploy.sh \
--config-drive true \
--file /root/db_env.rc=$HOME/db_env.rc \
--file /root/api_env.rc=$HOME/api_env.rc \
--file /root/os_env.rc=$HOME/os_env.rc \
$OS_USERNAME-api
!!
Note: Hostname "api"
openstack server list --format json | jq .
openstack server list --format json | \
jq -r '.[] | select(.Name == "'"$OS_USERNAME-api"'").Networks'
openstack server list --format json | \
jq -r '.[] | select(.Name == "'"$OS_USERNAME-api"'").Networks' | \
sed "s/.*private=\(.*\)/\1/"
cat <<EOF > $HOME/api_ips.rc
export WM_IPS=(
$(openstack server list --format json | \
jq -r '.[] | select(.Name == "'"$OS_USERNAME-api"'").Networks' | \
sed "s/.*private=\(.*\)/\1/")
)
EOF
more $HOME/api_ips.rc
ssh -i $HOME/.ssh/id_rsa.qcon_deploy root@any.api.server.ip
tail -f /var/log/cloud-init-output.log
tail -f /var/log/syslog
more $HOME/app-on-openstack/code/api/wm_api.log
exit
curl any.api.server.ip
openstack server create \
--image "$IMAGE_NAME" \
--flavor $FLAVOR_ID \
--key-name $OS_USERNAME-qcon \
--user-data $HOME/app-on-openstack/code/lb/deploy.sh \
--config-drive true \
--file /root/ips.rc=$HOME/api_ips.rc \
$OS_USERNAME-api-lb
Note: Hostname "api-lb"
Note: Stateless
cat <<EOF > $HOME/api_lb_ip.rc
export WM_API_LB_IP=$(openstack server list --format json | \
jq -r '.[] | select(.Name == "'"$OS_USERNAME-api-lb"'").Networks' | \
sed "s/.*private=\(.*\)/\1/")
EOF
source $HOME/api_lb_ip.rc
more $HOME/api_lb_ip.rc
curl $WM_API_LB_IP
Note: Try it in your browser (but be patient)
Note: Stateless
cat <<EOF > $HOME/worker_env.rc
export WM_API_SCHEME=http
export WM_API_ENDPOINT=$WM_API_LB_IP
export WM_CONFIG_ENV=testing
EOF
more $HOME/worker_env.rc
openstack server create \
--image "$IMAGE_NAME" \
--flavor $FLAVOR_ID \
--key-name $OS_USERNAME-qcon \
--user-data $HOME/app-on-openstack/code/worker/deploy.sh \
--config-drive true \
--file /root/os_env.rc=$HOME/os_env.rc \
--file /root/worker_env.rc=$HOME/worker_env.rc \
$OS_USERNAME-worker
!!
Note: Hostname "worker"
ssh -i $HOME/.ssh/id_rsa.qcon_deploy root@any.worker.server.ip
tail -f /var/log/cloud-init-output.log
tail -f /var/log/syslog
more $HOME/app-on-openstack/code/worker/wm_worker.log
exit
Note: Stateless
source $HOME/api_lb_ip.rc
cat <<EOF > $HOME/app_env.rc
export WM_API_SCHEME=http
export WM_API_ENDPOINT=$WM_API_LB_IP
export WM_CONFIG_ENV=testing
EOF
more $HOME/app_env.rc
openstack server create \
--image "$IMAGE_NAME" \
--flavor $FLAVOR_ID \
--key-name $OS_USERNAME-qcon \
--user-data $HOME/app-on-openstack/code/app/deploy.sh \
--config-drive true \
--file /root/app_env.rc=$HOME/app_env.rc \
--file /root/os_env.rc=$HOME/os_env.rc \
$OS_USERNAME-app
!!
Note: Hostname "app"
ssh -i $HOME/.ssh/id_rsa.qcon_deploy root@any.app.server.ip
tail -f /var/log/cloud-init-output.log
tail -f /var/log/syslog
more $HOME/app-on-openstack/code/app/wm_app.log
exit
curl any.app.server.ip
cat <<EOF > $HOME/app_ips.rc
export WM_IPS=(
$(openstack server list --format json | \
jq -r '.[] | select(.Name == "'"$OS_USERNAME-app"'").Networks' | \
sed "s/.*private=\(.*\)/\1/")
)
EOF
more $HOME/app_ips.rc
openstack server create \
--image "$IMAGE_NAME" \
--flavor $FLAVOR_ID \
--key-name $OS_USERNAME-qcon \
--user-data $HOME/app-on-openstack/code/lb/deploy.sh \
--config-drive true \
--file /root/ips.rc=$HOME/app_ips.rc \
$OS_USERNAME-app-lb
Note: Hostname "app-lb"
Note: Stateless
openstack server list | grep $OS_USERNAME
curl my.app.lb.server
Note: Try it in your browser (but be patient)
Note: Stateful
Everett Toews | @everett_toews |
Dana Bauer | @geography76 |