Portable PG applications
the Cloud
"what is it made of?"
The cloud is:
* Many are VM / VPS-based services
OR - if your Ops team offers pre-built VMs:
As a sysadmin:
* usually VM-based or proprietary application container technologies
the public cloud
This all sounds great, but what about…
Built around Containers
When "Big Cloud" fails you, you can always decide to host your own
Reusable, Redeployable code - host it anywhere
https://github.com/openshift-quickstart/tiny_tiny_rss-openshift-quickstart
rhc app create rss php-5 postgresql-9 cron-1.4 --from-code=https://github.com/openshift-quickstart/tiny_tiny_rss-openshift-quickstart.git
rhc cartridge add postgres-8.4
rhc cartridge add postgres-9.2
done!
rhc app show rss
Or, while connected over ssh:
env | grep DB
OPENSHIFT_POSTGRESQL_DB_PASSWORD=lXcFVx4hIZgR
OPENSHIFT_POSTGRESQL_DB_SOCKET=/var/lib/openshift/523672f7e0b8cd02d70003bc/postgresql/socket/
OPENSHIFT_POSTGRESQL_DB_HOST=127.7.8.130
OPENSHIFT_POSTGRESQL_DB_PID=/var/lib/openshift/523672f7e0b8cd02d70003bc/postgresql/pid/postgres.pid
OPENSHIFT_POSTGRESQL_DB_USERNAME=adminpahue6e
OPENSHIFT_POSTGRESQL_DB_URL=postgresql://adminpahue6e:lXcFVx4hIZgR@127.7.8.130:5432
OPENSHIFT_POSTGRESQL_DB_PORT=5432
OPENSHIFT_POSTGRESQL_DB_LOG_DIR=/var/lib/openshift/523672f7e0b8cd02d70003bc/postgresql/log/
https://github.com/shekhargulati/todo-flask-openshift-quickstart
blog post: Build Your App on OpenShift Using Flask, SQLAlchemy, and PostgreSQL 9.2
rhc app create -s task python-2.7 postgresql-9.2 --from-code=https://github.com/shekhargulati/todo-flask-openshift-quickstart.git
Setting a min and max scale from the command line
rhc cartridge-scale python-2.7 -a task --min 3 --max 5
Adding and removing instances / scaling up and down
haproxy_ctld --up
haproxy_ctld --down
HAProxy on / off switches
haproxy_ctld_daemon start
haproxy_ctld_daemon stop
haproxy_ctld_daemon restart
These hooks are available on the command line within your gear, and via a REST API
http://$YOUR_APP_DNS/haproxy-status/
http://$YOUR_APP_DNS/haproxy-status/;csv
Code for America
https://github.com/openshift-quickstart/adopt-a-hydrant-openshift-quickstart
This app should be using PostGIS for spatial queries:
Persist configuration details,
while keeping your source clean:
rhc app create hydrant ruby-1.9 postgresql-8.4 --from=code=http://github.com/ryanj/adopt-a-hydrant.git --env SECRET_TOKEN="YOUR_SECRET_TOKEN"
Listing your custom env vars:
cd hydrant
rhc env list
Setting a variable:
rhc env set SECRET_TOKEN="a1fdacc3b1d14d6a92ed1219ed304d02529f535085262a90c39f072ef6de0ee9fe3a3d0194f02a2a8eb3"
Help with configuration:
rhc help env
Automatic support for dependency resolution using standard packaging, native to each language:
gems (ruby), eggs (python), and npm modules (node.js)
with PostGIS
https://github.com/ryanj/flask-postGIS/tree/master/.openshift/action_hooks
http://parkgis-shifter.rhcloud.com/
Check out the upstream source:
OpenShift Origin
Try our hosted solution (3 apps free):
OpenShift Online
Request an evaluation for:
OpenShift Enterprise
Thanks for following along! --ryanj
slides: http://bit.ly/1eddml6