Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Apache jclouds - ApacheCon EU 2014

Introduction to Apache jclouds - ApacheCon EU 2014

Introduction to Apache jclouds talk given at ApacheCon EU 2014.

Apache jclouds is an open source multi-cloud toolkit for the Java platform that gives you the freedom to create applications that are portable across clouds while giving you full control to use cloud-specific features.

4ca6230b05046f1a809835985b1f8bc2?s=128

Ignasi Barrera

November 19, 2014
Tweet

Transcript

  1. Introduction to Apache jclouds Ignasi Barrera

  2. Agenda •  What is Apache jclouds? •  The community • 

    What does it do? •  Customization •  Code examples •  Roadmap: what’s next? 19/11/14   Introduc.on  to  Apache  jclouds   2  
  3. What is Apache jclouds? An open source multi-cloud toolkit for

    the Java platform 19/11/14   Introduc.on  to  Apache  jclouds   3  
  4. Why does multi-cloud matter? •  High availability •  Privacy • 

    Cost •  Performance •  Support One size does not fit all Avoid lock-in 19/11/14   Introduc.on  to  Apache  jclouds   4  
  5. What does it do? Helps existing tools connect to cloud

    services •  Consistent integration pattern •  Pluggable components •  Addresses service quirks in a clean way •  Error/retry handling •  Pagination •  (Re)Authentication 19/11/14   Introduc.on  to  Apache  jclouds   5  
  6. How does it keep quality? Supporting many providers is hard:

    •  APIs / Services change •  Providers can become obsolete •  Contributions have to be maintained •  … Unit + Live tests 19/11/14   Introduc.on  to  Apache  jclouds   6  
  7. ~" Community" ~

  8. Community stats •  Started on April 2009 •  +12K total

    commits •  ~200 contributors (65 last year) •  +200 forks on GitHub 19/11/14   Introduc.on  to  Apache  jclouds   8  
  9. Who uses Apache jclouds? 19/11/14   Introduc.on  to  Apache  jclouds

      9  
  10. ~" Core concepts" ~

  11. Locations 19/11/14   Introduc.on  to  Apache  jclouds   11  

    Locations help normalize placement across resource types All top-level resources have a location US-­‐CA   DE-­‐HE   BR-­‐SP   CH-­‐ZH   JP-­‐13  
  12. APIs 19/11/14   Introduc.on  to  Apache  jclouds   12  

    API Custom endpoint Credentials … APIs are the Java translation of API docs. Abiquo, Nova, CloudStack, EC2
  13. Providers 19/11/14   Introduc.on  to  Apache  jclouds   13  

    PROVIDER API LOCATION+DEFAULTS Configuration Providers represent concrete cloud services: API + location + defaults AWS, Google Compute Engine, DigitalOcean…
  14. Pluggable strategies 19/11/14   Introduc.on  to  Apache  jclouds   14

      PROVIDER Configuration Pluggable strategies, error & retry policies, pagination, drivers API LOCATION+DEFAULTS
  15. Portable abstractions 19/11/14   Introduc.on  to  Apache  jclouds   15

      API PROVIDER SERVICES MODEL Compute Blob Store Load Balancer
  16. ~" Show me the code!" ~

  17. Connection to a Provider ContextBuilder.newBuilder(”google-compute-engine") .credentials(”account-email", ”private-key") .buildView(ComputeServiceContext.class); 19/11/14  

    Introduc.on  to  Apache  jclouds   17  
  18. Connection to an API ContextBuilder.newBuilder(”google-compute-engine") .credentials(”account-email", ”private-key") .buildView(ComputeServiceContext.class); ComputeServiceContext ctx

    = ContextBuilder.newBuilder(”openstack-nova") .credentials(”tenant:user", ”password") .endpoint(“http://keystone.endpoint:5000/v2.0/”) .buildView(ComputeServiceContext.class); 19/11/14   Introduc.on  to  Apache  jclouds   18  
  19. Getting the services ContextBuilder.newBuilder(”google-compute-engine") .credentials(”account-email", ”private-key") .buildView(ComputeServiceContext.class); ComputeServiceContext ctx =

    ContextBuilder.newBuilder(”openstack-nova") .credentials(”tenant:user", ”password") .endpoint(“http://keystone.endpoint:5000/v2.0/”) .buildView(ComputeServiceContext.class); ComputeService compute = ctx.getComputeService(); NovaApi nova = ctx.unwrapApi(NovaApi. class); 19/11/14   Introduc.on  to  Apache  jclouds   19  
  20. Compute example ComputeService compute = ctx.getComputeService(); Template template = compute.templateBuilder()

    .osFamily(OsFamily.UBUNTU) .minRam(2048) .options(inboundPorts(22, 80)) .build(); compute.createNodesInGroup(”webfarm", 10, template); 19/11/14   Introduc.on  to  Apache  jclouds   20  
  21. Configuring nodes compute.runScriptOnNode(“i-3142”, startTomcat, blockOnPort(8080, 300)) compute.runScriptOnNodesMatching(inGroup(“webfarm”), patchApache, blockOnComplete(false)) compute.submitScriptOnNode(“i-3142”,

    runChefSolo, RunScriptOptions.NONE) 19/11/14   Introduc.on  to  Apache  jclouds   21  
  22. Accessing the nodes SshClient ssh = ctx.utils().sshForNode().apply(node); 19/11/14   Introduc.on

     to  Apache  jclouds   22  
  23. Accessing the nodes SshClient ssh = ctx.utils().sshForNode().apply(node); ssh.get(“/etc/passwd”); ssh.put(“/opt/conf.tar”, newFilePayload(new

    File(“conf.tar”))); ExecResponse result = ssh.exec(installJDK); ExecChannel channel = ssh.execChannel(runChefSolo); 19/11/14   Introduc.on  to  Apache  jclouds   23  
  24. ~" Customization" ~

  25. Drivers Drivers configure specific strategies to perform concrete tasks 19/11/14

      Introduc.on  to  Apache  jclouds   25   Logging slf4j, log4j, java logging SSH jsch, sshj HTTP ApacheHC, OkHttp, GAE I/O Netty Security Bouncycastle
  26. Context properties Context properties can be used to override the

    default values Properties props = new Properties(); props.setProperty(PROPERTY_MAX_RETRIES, “5”); ContextBuilder.newBuilder(”google-compute-engine") .credentials(”account-email", ”private-key") .overrides(props) .buildView(ComputeServiceContext.class); 19/11/14   Introduc.on  to  Apache  jclouds   26  
  27. Custom Guice modules Custom Guice modules can be configured to

    override the default behavior List<Module> modules = new ArrayList<Module>(); modules.add(new SLF4JLoggingModule()); ContextBuilder.newBuilder(”google-compute-engine") .credentials(”account-email", ”private-key") .modules(modules) .buildView(ComputeServiceContext.class); 19/11/14   Introduc.on  to  Apache  jclouds   27  
  28. ~" Roadmap" ~

  29. Roadmap •  Finish shiny new clouds such as Google and

    Docker •  Cleanup labs providers: nuke and promote! •  More vendor engagement •  Better support for Android and other platforms •  Improve the community! 19/11/14   Introduc.on  to  Apache  jclouds   29  
  30. Getting involved •  Talk to us –  Participate in our

    mailing lists –  Join the #jclouds IRC channel at Freenode •  Contribute code –  We use GitHub. Just raise a pull request! •  Contribute documentation –  You don’t even need to checkout the code of the site. Our walk n’ doc allows you to edit every page on-the-fly! 19/11/14   Introduc.on  to  Apache  jclouds   30  
  31. Thank you!" ~" http://jclouds.apache.org