Cloud Foundry Summit 2015: A Year of Innovation: Cloud Foundry Lessons Learned
Python on Cloud Foundry
-
Upload
ian-huston -
Category
Technology
-
view
1.028 -
download
8
description
Transcript of Python on Cloud Foundry
@ianhuston 1 © Copyright 2014 Pivotal. All rights reserved. 1 © Copyright 2014 Pivotal. All rights reserved.
Python on Cloud Foundry
Ian Huston, Data Scientist
@ianhuston 2 © Copyright 2014 Pivotal. All rights reserved.
Who am I?
� Ian Huston
� @ianhuston
� github.com/ihuston
� www.ianhuston.net
� Talk resources: http://tinyurl.com/pythonCF
� Data Scientist
� Use PyData stack for predictive analytics and machine learning
� Previously a theoretical physicist using Python for numerical simulations & HPC
@ianhuston 3 © Copyright 2014 Pivotal. All rights reserved.
What is Cloud Foundry?
http://cloudfoundry.org
Open Source Cloud Platform
Simple App Deployment, Scaling & Availability
@ianhuston 4 © Copyright 2014 Pivotal. All rights reserved.
Cloud Foundry Foundation: Industry Standard
Gold
Silver
@ianhuston 5 © Copyright 2014 Pivotal. All rights reserved.
CF for data scientists & developers Easily deploy your web app
cf push Scale up and out quickly
cf scale myapp –i 5 –m 1G Create and bind services
cf bind-‐service myapp redis
@ianhuston 6 © Copyright 2014 Pivotal. All rights reserved.
mod proxy
1. The platform takes care of all the steps on the left automatically
50 Configuration Touches
1. Register Hostname with DNS (1) 2. Configure F5 Load Balancing Group (2) 3. Configure Apache HTTPd Worker Pool (4) 4. Configure mod_proxy Connector Routing (4) 5. Configure Tomcat Connector Pool (40)
1 Configuration Touch
1 2 4 4 40 1
Cloud Foundry: From 50 touch points to 1
@ianhuston 7 © Copyright 2014 Pivotal. All rights reserved. 7 © Copyright 2014 Pivotal. All rights reserved.
Python & CF
@ianhuston 8 © Copyright 2014 Pivotal. All rights reserved.
Python on Cloud Foundry
� First class language (with Go, Java, Ruby, Node.js, PHP)
� Automatic app type detection
� Buildpack takes care of – Installing Python interpreter – Installing packages in requirements.txt using pip – Starting web app as requested (e.g. python myapp.py)
@ianhuston 9 © Copyright 2014 Pivotal. All rights reserved.
Simple Flask App Demo � Simple one page “Hello World” web app
� Video: https://www.youtube.com/watch?v=QOfD6tnoAB8
� Demonstrates: – Installation of requirements – Scaling properties
� Need to Provide: – App files – Dependencies listed in requirements.txt file – Optional manifest.yml file with configuration for deployment
@ianhuston 10 © Copyright 2014 Pivotal. All rights reserved.
Data Services
� Easy to bind and scale services – Databases, NoSQL, message queues etc. $ cf create-‐service rediscloud PLAN_NAME INSTANCE_NAME $ cf bind-‐service APP_NAME INSTANCE_NAME
� Details provided in VCAP_APP_SERVICES env variable: { "rediscloud": [ { "name": "rediscloud-‐42", "label": "rediscloud", "plan": "20mb", "credentials": { "port"": "6379",
"hostname": "pub-‐redis-‐6379.us-‐east-‐1-‐2.3.ec2.redislabs.com", "password": "your_redis_password” } } ] }
@ianhuston 11 © Copyright 2014 Pivotal. All rights reserved.
Services now available These are available on Pivotal CF (Pivotal’s packaged Cloud Foundry offering).
See http://run.pivotal.io for the services available on Pivotal Web Services.
@ianhuston 12 © Copyright 2014 Pivotal. All rights reserved.
PyData stack on CF: conda +
• Use (mini)conda to provide Python & package installation
• Quickly install needed PyData packages • Can even provision your own IPython notebook
server [at your own risk!]
CF Buildpack: https://github.com/ihuston/python-conda-buildpack
@ianhuston 13 © Copyright 2014 Pivotal. All rights reserved. 13 © Copyright 2014 Pivotal. All rights reserved.
Why?
@ianhuston 14 © Copyright 2014 Pivotal. All rights reserved.
Benefits for Data Scientists
� Easy to get web apps up and running
� Create and bind to your favourite data services
� Don’t get locked in to one cloud provider
� Python is officially supported
@ianhuston 15 © Copyright 2014 Pivotal. All rights reserved.
Try Cloud Foundry today!
Pivotal Web Services: http://run.pivotal.io IBM Bluemix: http://bluemix.net Anynines: http://anynines.com
HP Helion: http://horizon.hpcloud.com
@ianhuston 16 © Copyright 2014 Pivotal. All rights reserved.
More info and resources
� Material for this talk: http://tinyurl.com/pythonCF
� Cloud Foundry: http://cloudfoundry.org
� Flask Mega Meta Tutorial for DS: http://tinyurl.com/flaskDS
� Twelve Factor Apps: http://12factor.net/
� Meetups: http://cloud-foundry.meetup.com/
@ianhuston 17 © Copyright 2014 Pivotal. All rights reserved. 17 © Copyright 2014 Pivotal. All rights reserved.
Appendix Docker & Cloud Foundry
@ianhuston 18 © Copyright 2014 Pivotal. All rights reserved.
Docker joins the Cloud Foundry Foundation in May 2014 to support Cloud Foundry open governance and advance the state of containers in Platform as a Service
CF and Docker
@ianhuston 19 © Copyright 2014 Pivotal. All rights reserved.
Docker Benefit: Customize More Layers of the App
runtime layer
OS image
application layer
Docker
system brings fixed host OS Kernel
* Devs may bring a custom buildpack
runtime layer*
OS image
application layer
Buildpack
system brings fixed host OS Kernel
App container
System Provides
Dev Provides
@ianhuston 20 © Copyright 2014 Pivotal. All rights reserved.
Coming soon to Cloud Foundry � Planned to support Cloud Foundry apps from: – Linux Buildpacks – Windows .NET Buildpacks powered by Iron Foundry – Docker images
� Docker applications will work similar to apps from buildpacks – Same scaling & services bindings, same CLI commands push etc