pallet bacug

Upload: tbatchelli

Post on 10-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Pallet Bacug

    1/32

    So Clojure walks into a

    cloud...@tbatchelli

    a.k.a. @disclojure

    Oct 7th 2010

    1Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    2/32

    What?

    Functionally deploy and manage yourapplications in the cloud, using the sameartifacts during all stages in the applicationlifecycle:

    Development

    Integration Tests

    Production

    Which cloud provider?- Any provider! All providers!

    2Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    3/32

  • 8/8/2019 Pallet Bacug

    4/32

    What do they do?

    jclouds manages the infrastructure in acloud-provider agnostic way

    pallet sits both on above and belowjclouds to:- coordinate the infrastructure creation/

    destruction/cycling- configure and manage the nodes

    4Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    5/32

    jclouds

    Templates abstractly describe nodes:- What OS to use, what versions...- What kind of hardware, what features are needed...

    Tags organize identically configured nodes in groups You can create, destroy, reboot tags

    - Also, manage keys pairs, security group config, etc...

    Works across almost every cloud provider (see list)Note: jclouds does much more than what well seehere!

    5Wednesday, October 13, 2010

    http://code.google.com/p/jclouds/http://code.google.com/p/jclouds/http://code.google.com/p/jclouds/
  • 8/8/2019 Pallet Bacug

    6/32

    REPL time!

    6Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    7/32

    Pallet

    High level management of node tags (groups) Setup and configuration of tags, even different

    tags at once and in a coordinated way

    Configuration of services in nodes, done viacrates, pre-packaged configuration elements.

    Is agentless: uses vanilla images and does not

    install any agent.

    No central server either.

    7Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    8/32

    pallet performs little things

    Setup an admin account that you can use right awayfor ssh Install desired software on each node

    Copy files to nodes Create and configure multi-node multi-serviceconfigurations (well see this)

    ... dunno, setup a fully configured --to your liking--hudson build manager?

    Oh! and do all the above in usually done in oneshot, applied to as many nodes you want.

    8Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    9/32

    Crates

    Configuration components nagios, hudson, tomcat, couchdb, haproxy...* You customize crates by configuration, as

    opposed to forking and editing them.

    Complex crates are usually DSL Usually youll create your own lightweight crates

    that will use standard crates* talk to Hugo Duncan if your favorite service is not yetsupported

    9Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    10/32

    Webapp node(core/defnodewebapp"Basicwebapp,servedbytomcat"

    {:os-family:ubuntu

    :os-description-matches"10.04"

    :inbound-ports[808022]}:bootstrap(resource/phase(crates/bootstrap))

    :configure(resource/phase(crates/tomcat))

    :deploy(resource/phase

    (crates/tomcat-deploy"webapp.war"))

    :restart-tomcat(resource/phase

    (service/service"tomcat6"

    :action:restart)))

    10Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    11/32

    Webapp node(core/defnodewebapp"Basicwebapp,servedbytomcat"

    {:os-family:ubuntu

    :os-description-matches"10.04"

    :inbound-ports[808022]}:bootstrap(resource/phase(crates/bootstrap))

    :configure(resource/phase(crates/tomcat))

    :deploy(resource/phase

    (crates/tomcat-deploy"webapp.war"))

    :restart-tomcat(resource/phase

    (service/service"tomcat6"

    :action:restart)))

    11Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    12/32

    Webapp node(core/defnodewebapp"Basicwebapp,servedbytomcat"

    {:os-family:ubuntu

    :os-description-matches"10.04"

    :inbound-ports[808022]}:bootstrap(resource/phase(crates/bootstrap))

    :configure(resource/phase(crates/tomcat))

    :deploy(resource/phase

    (crates/tomcat-deploy"webapp.war"))

    :restart-tomcat(resource/phase

    (service/service"tomcat6"

    :action:restart)))

    12Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    13/32

    Alright, get it done

    (pallet.core/converge

    {webapp1}

    :computeservice

    :phase:deploy)

    13Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    14/32

  • 8/8/2019 Pallet Bacug

    15/32

    How to deal withmulti-tag setups?

    15Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    16/32

    proxied

    (webapp)

    proxied

    (webapp)

    proxied

    (webapp)

    HAproxy

    the

    lolcats-net

    16Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    17/32

    two-phase model1. Invoke: for each phase (bootsrap,

    configure, deploy, etc...), on all nodes of

    each tag, call the crates. This generates:

    - An intermediate representation of boththe particular and the global configuration- A list of the tasks to perform to setup the

    nodes up to that configuration level needed

    2. Execute all listed tasks based on the final

    configuration created in the previous step

    17Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    18/32

    the invoke step

    foreachphase

    foreachtag

    foreachnodeintag

    invoke-phaseonnodeintag

    18Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    19/32

    the invoke step

    Each phase, amongst other things, adds:

    - New configuration data to the :parameters key- New resources to the :invocations key. These

    resources are functions that will ultimately resultin a resource on the node (config file, script,

    etc..)

    19Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    20/32

    example

    haproxy crate- Schedules the creation its configuration based

    on the the proxied nodes added in :parameters

    - the actual creation of the configuration will bedone in the next step

    proxied crate

    - for every proxied node it will create an entryin :parameters

    20Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    21/32

    Proxy/Proxied

    (core/defnodeproxied

    "Aproxiedwebapp"

    {:os-family:ubuntu

    :os-description-matches"10.04"

    :inbound-ports[808022]}

    :bootstrap(resource/phase(crates/bootstrap))

    :configure(resource/phase(crates/tomcat)

    (crates/reverse-proxy:haproxy

    :app18080))

    :deploy(resource/phase(crates/tomcat-deploy"mini-webapp.war"))

    :restart-tomcat(resource/phase

    (service/service"tomcat6"

    :action:restart)))

    21Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    22/32

    Proxy/Proxied

    (core/defnodehaproxy

    "Simplehaproxy"

    {:image-id"us-east-1/ami-6006f309"

    :inbound-ports[8022]}:bootstrap(resource/phase

    (crates/bootstrap))

    :configure(resource/phase

    (crates/haproxy))

    :restart-haproxy(resource/phase

    (service/service"haproxy":action:restart)))

    22Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    23/32

    :parameters

    {:haproxy

  • 8/8/2019 Pallet Bacug

    24/32

    :invocations{

    ....

    :configure

  • 8/8/2019 Pallet Bacug

    25/32

    the execute step

    foreachphase

    foreachtag

    foreachnodeintag

    build-commands

    execute-with-ssh

    25Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    26/32

    the execute step

    build the actual files and scripts to becreated and executed, based onthe :parameters

    Execute the scripts on the node via ssh,

    move files, etc...

    26Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    27/32

  • 8/8/2019 Pallet Bacug

    28/32

    Proxy/Proxied

    (pallet.core/converge

    {proxied10haproxy1}

    :computeservice

    :phase:deploy)

    28Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    29/32

    Notes on resources

    Resources (files, scripts) are computed duringbuild time, but they are built at executiontime and on the node; this allows for variable

    expansion based on the target node- i.e. $home/bin/java

    Stevedore (also Hugo Duncans brain

    child)builds bash scripts from a clojure DSL,with variable escaping similar to macros.Stevedore deserves a talk on its own.

    29Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    30/32

  • 8/8/2019 Pallet Bacug

    31/32

    other notes

    Easy to do dry-runs

    - jclouds has a stub provider- pallet has a with-no-compute-service and wrap-

    no-exec middleware

    Easy to unit-test crates

    31Wednesday, October 13, 2010

  • 8/8/2019 Pallet Bacug

    32/32

    thank you

    visit- www.pallet.org- www.jclouds.org

    - #pallet on IRC- #jclouds on IRC- @hugoduncan on twitter- @jclouds on twitter- and ofcourse www.disclojure.org

    http://www.jclouds.org/http://www.pallet.org/http://www.jclouds.org/http://www.jclouds.org/http://www.pallet.org/http://www.pallet.org/