Docker for Multi-Cloud Apps

27
For Multi-Cloud Apps Docker

Transcript of Docker for Multi-Cloud Apps

Page 1: Docker for Multi-Cloud Apps

For Multi-Cloud Apps

Docker

Page 2: Docker for Multi-Cloud Apps

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)

Page 3: Docker for Multi-Cloud Apps

Containers for Multi-Cloud Apps

3www.rackspace.com

Page 4: Docker for Multi-Cloud Apps

21

App

Yes, Cloud Portability

Page 5: Docker for Multi-Cloud Apps

App 2

No, Don’t Straddle Clouds

1

Page 6: Docker for Multi-Cloud Apps

Writing Portable Cloud Apps

•Fog (Ruby)

•Apache Libcloud (Python)

•Apache Jclouds (Java)

•Gophercloud (Go)

•…

Page 7: Docker for Multi-Cloud Apps

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

Page 8: Docker for Multi-Cloud Apps

8www.rackspace.com

Yeah, but what if…

Page 9: Docker for Multi-Cloud Apps

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?

Page 10: Docker for Multi-Cloud Apps
Page 11: Docker for Multi-Cloud Apps

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

Page 12: Docker for Multi-Cloud Apps

What’s a Dockerfile?

FROM centos

MAINTAINER [email protected]

RUN yum -y install httpd

EXPOSE 80

ADD start.sh /start.sh

CMD /start.sh

Page 13: Docker for Multi-Cloud Apps

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>]

Page 14: Docker for Multi-Cloud Apps

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

Page 15: Docker for Multi-Cloud Apps

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.

Page 16: Docker for Multi-Cloud Apps

Example HOT File with Dependency

resources:

server1:

type: OS::Nova::Server

depends_on: database_server

database_server:

type: OS::Trove::Instance

properties: …

Page 17: Docker for Multi-Cloud Apps

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)

Page 18: Docker for Multi-Cloud Apps

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

Page 19: Docker for Multi-Cloud Apps

Swarm == Cool.

• Combined view of multiple cloud hosts

• Ability to selectively run containers on any of them

CLI Swarmd 2

1

N

Page 20: Docker for Multi-Cloud Apps

Best Practice: Clouds want cattle, not pets.

Page 21: Docker for Multi-Cloud Apps

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.

Page 22: Docker for Multi-Cloud Apps

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

Page 23: Docker for Multi-Cloud Apps

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

Page 24: Docker for Multi-Cloud Apps

•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

Page 25: Docker for Multi-Cloud Apps

$ 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

Page 26: Docker for Multi-Cloud Apps

$ 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

Page 27: Docker for Multi-Cloud Apps

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