For Multi-Cloud Apps
Docker
Adrian Otto
•Principal Architect, Rackspace
•Chair of OpenStack Containers Team
•PTL of Magnum (Containers-as-a-Service for OpenStack)
•PTL of Solum (CI/CD for OpenStack)
•Co-Chair of OASIS CAMP TC (Cloud Standards)
Containers for Multi-Cloud Apps
3www.rackspace.com
21
App
Yes, Cloud Portability
App 2
No, Don’t Straddle Clouds
1
Writing Portable Cloud Apps
•Fog (Ruby)
•Apache Libcloud (Python)
•Apache Jclouds (Java)
•Gophercloud (Go)
•…
Handling Existing Apps - Overview
• Containerize
– Use a Dockerfile to create a container image
– Store the image in a repository
• Run Docker on your cloud servers
• Back up your data to storage in the target cloud
• Load your app image from the repo to run it
• Load your data from your backup
8www.rackspace.com
Yeah, but what if…
I have a *lot* of cloud servers
I have a *lot* of data!
My app needs a separate database server
What’s Docker?What’s an image repository?
What’s a Dockerfile?
What’s Docker?
• Allows for simplified management of containers
– CLI, API
– Example: docker run -p 80:80 web:latest
• Docker container is an amalgam
Cgroups Namespaces ImageDocker
Container
What’s a Dockerfile?
FROM centos
MAINTAINER [email protected]
RUN yum -y install httpd
EXPOSE 80
ADD start.sh /start.sh
CMD /start.sh
What’s an image repository?
• A place to store Docker container images
• Works just like a Git repository– docker pull <name>
– docker push <name>[:<tag>]
I have a *lot* of cloud servers
•You need a utility with a resource scheduler–Nova, Magnum, Kubernetes, Mesos, Swarm, etc.
•Treat application servers like cattle–Create them from container images using automation
My app needs a separate database server
• Your database is also an app
• Bind mount your data volume from the host
–Example:
•docker run -v /data/my_app:/my_app –p 3306:3306 mysql:latest
• All prevailing orchestration systems allow you to define prerequisites.
• Using Heat
–Output of one resource can be the input to another.
Example HOT File with Dependency
resources:
server1:
type: OS::Nova::Server
depends_on: database_server
database_server:
type: OS::Trove::Instance
properties: …
I have a *lot* of data
•Don’t put “data” in containers
•Replicate your data in each target cloud
•Use prevailing techniques for incrementally streaming changes to your replicas
•Bind mount your data volume(s) to your container(s)
Swarm - https://github.com/docker/swarm
• Exposes a cluster of Docker hosts as one virtual host
• Provides a Docker API
• Includes Resource Scheduling
– Filters: Constraint, Affinity, Port, Health
– Strategies: Bin Packing, Random
• A swarm agent runs on each Docker host
Swarm == Cool.
• Combined view of multiple cloud hosts
• Ability to selectively run containers on any of them
CLI Swarmd 2
1
N
Best Practice: Clouds want cattle, not pets.
How do I make cattle?
• Have a Dockerfile for each app
• Create Docker Images
• Deploy applications in containers
• Use scripted orchestration for app deployment
– Heat, Ansible, Chef, Puppet, etc.
• Use a centralized log scheme
– Logstash, Greylog, Kibana, etc.
Best Practice: Immutable Infrastructure
•Run the same artifacts everywhere
–Test
–Staging
–Production
•Rationale
–Less chance of environmental drift
–Helps you to bridge the gap from pets to cattle
23
Docker Topologies
www.rackspace.com
Hardware Hardware
VM
Kernel
Docker
Hypervisor
VM
Kernel Kernel
Docker Docker
C C
C C C C
C = Container
Bare Metal – Single Tenant Virtualized – Multi-Tenant
•Do it by hand
•Use a VM image with a docker daemon in it
•docker-machine - https://github.com/docker/machine
– Start machines on Cloud Servers
•AWS, Azure, Digital Ocean, GCE, Hyper V, Softlayer, Rackspace, OpenStack, VMWare vCloud Air, VMWare vSphere, Microsoft Windows (+caveat)
– Start machines on bare metal (OnMetal Flavors from Rackspace)
• But wait… there’s MORE!!!
24
Where do babies come from?
www.rackspace.com
$ export OS_REGION_NAME=IAD
$ export OS_USERNAME=jdoe
$ export OS_API_KEY=735590eaa1646e3ae79e6babbb7fd29f
$ docker-machine create -d rackspace demo
…
$ $(docker-machine env demo)
$ docker run -d centos:centos7 sleep 1d
…
873f3fa9e2924a4ef1de114628491af4026837f6cc2be8813f9515e532ad2c74
$
25
Use docker-machine to create VMs with Docker
www.rackspace.com
$ docker-machine create -d virtualbox foo
$ $(docker-machine env foo)
$ docker run --rm swarm create
ca6d7ef5272e0237b538cd685c26740d
$ docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://ca6d7ef5272e0237b538cd685c26740d swarm-master
$ $(docker-machine env --swarm swarm-master)
$ docker-machine create -d virtualbox --swarm --swarm-discovery token://ca6d7ef5272e0237b538cd685c26740d swarm-node-00
$ docker-machine create -d virtualbox --swarm --swarm-discovery token://ca6d7ef5272e0237b538cd685c26740d swarm-node-01
26
Use docker-machine to create swarms
www.rackspace.com
THANK YOU
RACKSPACE® | 1 FANATICAL PLACE, CITY OF WINDCREST | SAN ANTONIO, TX 78218
US SALES: 1-800-961-2888 | US SUPPORT: 1-800-961-4454 | WWW.RACKSPACE.COM
© RACKSPACE LTD. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED S TATES AND OTHER COUNTRIES. | WWW.RACKSPACE.COM
Top Related