22
Nguyen Anh Tu Apache CloudStack committer @ngtuna11 ngtuna.blogspot.com [email protected] An implementation

Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Nguyen Anh Tu Apache CloudStack committer

@ngtuna11 ngtuna.blogspot.com

[email protected]

An implementation

Page 2: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Agenda •  Docker – why it’s so magic? •  Docker in OpenStack •  What should I do with CloudStack ? •  Docker with PaaS - an example from Apache Stratos

Page 3: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Why it’s so magic?

Page 4: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 5: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 6: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 7: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 8: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 9: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 10: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

•  client.py – Docker client –  API version 1.4 –  list, create, start, stop container –  get, inspect image –  pull, push repository

•  driver.py – Docker Virt driver –  provisioning, snapshot instances –  setup network –  monitoring host capacity

•  hostinfo.py – host capacity –  memory usage –  disk usage

A look inside

Page 11: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 12: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Docker Resource

Agent Manager

Docker

Container A

Container B

Virtual Router

Docker-registry

agent.properties: hypervisor.type = docker resource = com.cloud.hypervisor.docker.resource.DockerResource

HTTP API

Cmd

Page 13: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Three ways to register template •  From a repository image •  From a dockerfile •  From a tar file

Page 14: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Docker hypervisor

Pipework

Virtual Router

•  Spawn container in network-less mode

•  CloudStack IP address allocator •  Network services from Virual Router

container •  Pipework

•  pipework br1 $VIRTUALROUTER 10.1.1.1/24 •  pipework br1 $CONTAINER 10.1.1.2/24

Network orchestration

https://github.com/jpetazzo/pipework

Page 15: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Docker HTTP request •  Docker server: /bin/bash –c docker –H <ipaddr>:5555 –d & •  Docker client:

String url = System.getProperty("docker.url", "http://<ipaddr>:5555"); dockerClient = new DockerClient(url);

•  Images: list, inspect, pull, commit, search ClientResponse response = dockerClient.pull(testImage);

•  Containers: list, create, start, stop, remove ContainerCreateResponse container = dockerClient.createContainer(containerConfig);

•  Build from Dockerfile File baseDir = new File(Thread.currentThread().getContextClassLoader().getResource(”path/to/folder").getFile()); ClientResponse response = dockerClient.build(baseDir);

•  Upload tar file InputStream tar = Thread.currentThread().getContextClassLoader().getResourceAsStream(”path/to/empty.tar"); String imageId = dockerClient.importImage("empty", null, tar).getId();

https://github.com/kpelykh/docker-java

Page 16: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Adding Docker hypervisor •  New plugin: cloud-plugin-hypervisor-docker

–  DockerResource »  a docker driver

–  DockerGuru »  setup container parameters for spawning

–  DockerServerDiscoverer »  to discover and register host to Agent Manager »  ton of tricks: connection checking, health checking,…

–  Docker HTTP request –  cloud-setup-agent

»  Config services on docker host: network, nfs, security policy, firewall,… »  update agent.properties »  start docker agent service

–  Agent, Agentshell, Agent Manager »  contact to hosts »  send cmd, health checking, connection checking

Page 17: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack
Page 18: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Apache Stratos Architecture

Page 19: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

IaaS layer

AWS EC2 IaaS Impl

Cloud Controller

OpenStack IaaS Impl

vCloud IaaS Impl

Apache jCloud

Page 20: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Two ways of integration •  Support IaaS providers supporting Docker hypervisor

Page 21: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Two ways of integration •  Support Docker directly from jCloud

https://github.com/andreaturli/jclouds-labs/tree/feature/docker/docker

Page 22: Why it’s so magic? - Apache Software Foundationpeople.apache.org/~tuna/integrating_docker_to_cloudstack_ccna14.… · • Docker – why it’s so magic? • Docker in OpenStack

Nguyen Anh Tu Apache CloudStack committer

@ngtuna11 ngtuna.blogspot.com

[email protected]

Thank you