Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cutting through the fog of cloud

1,342 views

Published on

In this presentation, I am going to briefly talk about 'what cloud is' and highlight the various types of cloud (IaaS, PaaS, SaaS). The bulk of the talk will be about using the fog gem using IaaS. I will discuss fog concepts (collections, models, requests, services, providers) and supporting these with actual examples using fog

Published in: Technology, Business
  • You have to choose carefully. ⇒ www.HelpWriting.net ⇐ offers a professional writing service. I highly recommend them. The papers are delivered on time and customers are their first priority. This is their website: ⇒ www.HelpWriting.net ⇐
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Did u try to use external powers for studying? Like ⇒ www.WritePaper.info ⇐ ? They helped me a lot once.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Cutting through the fog of cloud

  1. 1. Cutting Through The Fog Of Cloud Kyle Rames Developer Advocate @krames
  2. 2. Agenda • Cloud 101 • Working in the Clouds
  3. 3. What is Cloud?
  4. 4. Software as a Service SaaS
  5. 5. Platform as a Service PaaS
  6. 6. Infrastructure as a Service IaaS
  7. 7. Types of Cloud SaaS PaaS IaaS
  8. 8. When I say Cloud, you think...
  9. 9. When I say Cloud, you think...
  10. 10. Agenda • Cloud 101 • Working in the Clouds
  11. 11. source: https://www.ruby-toolbox.com/projects/fog
  12. 12. Fog Providers >>  Fog.providers.keys   =>  [:atmos,  :aws,  :baremetalcloud,    :bluebox,:brightbox,  :clodo,  :cloudsigma,  :clou dstack,  :digitalocean,  :dnsimple,  :dnsmadeeasy,   :dreamhost,  :dynect,  :ecloud,  :glesys,  :gogrid,   :google,  :hp,  :ibm,  :internetarchive,  :joyent,  : libvirt,  :linode,  :local,  :ninefold,  :openstack,   :openvz,  :ovirt,  :rackspace,  :riakcs,  :serverlov e,  :stormondemand,  :vcloud,  :vmfusion,  :voxel,  : vsphere,  :xenserver,  :zerigo]    
  13. 13. Rackspace Services >>  Fog.services.select  {|k,v|            v.include?(:rackspace)        }.keys   =>  [:storage,  :cdn,  :compute,  :dns,     :block_storage,  :compute_v2,  :load_balancers,  :i dentity,  :databases]
  14. 14. Load Balancer VMVM DNS bespin-mining.com
  15. 15. VMVM
  16. 16. Create Compute Service >>  service  =  Fog::Compute.new  {                                :provider  =>  'rackspace',                                :version  =>  :v2,                              :rackspace_username  =>  USERNAME,                              :rackspace_api_key  =>  API_KEY,                              :rackspace_region  =>  :ord
  17. 17. Required Server Parameters
  18. 18. Get List of Images >>  images  =  service.images   =>  <Fog::Compute::RackspaceV2::Images  [              <Fog::Compute::RackspaceV2::Image                  id="ccaf99bc-­‐472a-­‐46ea-­‐a125-­‐d3ecfca66695",                  name="FreeBSD  9.1",                  ...>,              <Fog::Compute::RackspaceV2::Image                  id="16e6c0ae-­‐f881-­‐4180-­‐95b0-­‐3450fe3f8e96",                  name="Red  Hat  Enterprise  Linux  6.4",                  ...>,            ...          ]>
  19. 19. Get Ubuntu Image >>  image  =  images.find  do  |img|              img.name  =~  /Ubuntu/        end       =>  <Fog::Compute::RackspaceV2::Image          id="23cebbc9-­‐3219-­‐4a27-­‐9210-­‐d63e1af7181b",          name="Ubuntu  13.04  (Raring  Ringtail)",          ...        >  
  20. 20. Get Flavor >>  flavor  =  service.flavors.first   =>  <Fog::Compute::RackspaceV2::Flavor          id="2",          name="512MB  Standard  Instance",          ram=nil,          disk=nil,          vcpus=nil,          links=[{"href"=>"https:// ord.servers.api.rackspacecloud.com/v2/772045/ flavors/2",  "rel"=>"self"},  {"href"=>"https:// ord.servers.api.rackspacecloud.com/772045/flavors/ 2",  "rel"=>"bookmark"}]  
  21. 21. TK-421
  22. 22. Create Server >>  tk_421  =  service.servers.create  {                                                        :image_id  =>  image.id,                                                          :flavor_id  =>  flavor.id,                                                          :name  =>  'TK-­‐421'}   =>  <Fog::Compute::RackspaceV2::Server          id="308e5fd5-­‐ff50-­‐42bd-­‐911c-­‐b91a9180673d",          name="TK-­‐421",          created=nil,          updated=nil,          host_id=nil,          state=nil,          progress=nil,          ...>
  23. 23. Update Server Object >>  tk_421.reload
 =>  <Fog::Compute::RackspaceV2::Server          id="308e5fd5-­‐ff50-­‐42bd-­‐911c-­‐b91a9180673d",          name="TK-­‐421",          created="2013-­‐07-­‐03T18:08:40Z",          updated="2013-­‐07-­‐03T18:08:43Z",          host_id="",          state="BUILD",          progress=0,        ...>
  24. 24. Server Attributes >>  tk_421.attributes   =>  {:image_id=>"23cebbc9-­‐3219-­‐4a27-­‐9210-­‐d63e1af7181b",   :flavor_id=>"2",  :name=>"TK-­‐421",  :disk_config=>"AUTO" ,  :id=>"308e5fd5-­‐ff50-­‐42bd-­‐911c-­‐ b91a9180673d"  :state=>"BUILD",  :progress=>0,     ...}
  25. 25. Fog Meta Magic >>  tk_421.state   =>  "BUILD"     >>  tk_421.progress   =>  0  
  26. 26. Is it ready? >>  tk_421.reload   >>  tk_421.state   =>  "BUILD"       >>  tk_421.progress   =>  17    
  27. 27. Waiting for TK-421 >>  tk_421.wait_for  {  ready?  }   =>  {:duration=>197.0}  
  28. 28. Login >>  tk_421.username   =>  “root”   >>  tk_421.password   =>  “r3b3lz-­‐st1nk42”
  29. 29. Bootstrap 1. Creates server 2. Waits for server to finish building 3. Create ROOT_USER/.ssh/authorized_keys 4. Lock password for root user 5. Create ROOT_USER/attributes.json file 6. Create ROOT_USER/metadata.json file
  30. 30. Bootstrap >>  tk_422  =  service.servers.bootstrap  {                :image_id  =>  image.id,                  :flavor_id  =>  flavor.id,                  :name  =>  'TK-­‐422',              :public_key_path  =>  '~/.ssh/fog_rsa.pub',                :private_key_path  =>  '~/.ssh/fog_rsa'        }
  31. 31. SCP / SSH >>  tk_422.scp  'setup.sh',  '/root/setup.sh'   >>  results  =  tk_422.ssh  ‘sh  /root/setup.sh’   >>  results.first.stdout   =>  "Setting  up  VMrn"  
  32. 32. We have only scratched the surface!
  33. 33. Remember? service.images
  34. 34. Collection Array Fog::Collection Fog::Compute::RackspaceV2::Images
  35. 35. Collection Methods all fetch every object of that type from the provider. get fetch a single object by its identity from the provider. create initialize a new record locally and a remote resource with the provider. new initialize a new record locally, but do not create a remote resource with the provider.
  36. 36. Collections >>  service.collections   [:servers,  :flavors,  :images,  :at tachments,  :networks]
  37. 37. Model Fog::Model Fog::Compute::RackspaceV2:Image
  38. 38. Model Methods attributes Returns a hash containing the list of model attributes and values. save Saves object. (not all object support update) reload Updates object with latest state from service. ready? Returns true if object is in a ready state and able to perform actions. wait_for Periodically reloads model yielding to block.
  39. 39. Model Layer
  40. 40. VMVM
  41. 41. Load Balancer VMVM
  42. 42. Create Load Balancer Service >>  lb_service  =            Fog::Rackspace::LoadBalancers.new  {                        :rackspace_username  =>  USERNAME,                      :rackspace_api_key  =>  API_KEY,                      :rackspace_region  =>  :ord              }
  43. 43. Load Balancer Collections >>  lb_service.collections   =>  [:load_balancers,  :nodes,  :virtual_ips,            :access_rules]  
  44. 44. Creating a Load Balancer lb  =  lb_service.load_balancers.
  45. 45. Creating a Load Balancer lb  =  lb_service.load_balancers.create        :name  =>  'bob-­‐the-­‐balancer',      :protocol  =>  'HTTP',        :port  =>  80,        :virtual_ips  =>  [{:type  =>  'PUBLIC'}],        :nodes  =>  [{                              :address  =>  tk_421.ipv4_address,                                :port  =>  80,                                :condition  =>  'ENABLED'                          }]  
  46. 46. Add Additional Node lb.nodes.
  47. 47. Add Additional Node lb.nodes.create  {   :address  =>  tk_422.ipv4_address,        :port  =>  80,        :condition  =>  'ENABLED'   }
  48. 48. IP Address >>  vip  =  lb.virtual_ips.find  do  |ip|                        ip.ip_version  ==  "IPV4"                    end   >>  vip.address   =>  "166.78.41.240"    
  49. 49. Continuous Deployment [tk_602,  tk_603].each  do  |server|        lb.nodes.create(:address  =>   server.ipv4_address,            :port  =>  80,            :condition  =>  'ENABLED')   end   existing_nodes.each  do  |node|        node.condition  =  'DRAINING'      node.save   end
  50. 50. Request Layer
  51. 51. Request Layer • Mirrors REST interface • Most efficient way to access cloud • Not portable between providers • Preference model layer!
  52. 52. Requests >>  service.requests   [:copy_object,  :delete_container,   :delete_object,  :get_container,  : get_containers,  :get_object,   ...]
  53. 53. Load Balancer VMVM
  54. 54. Load Balancer VMVM DNS bespin-mining.com
  55. 55. Create DNS Service >>  service  =  Fog::DNS.new  {                                :provider    =>  'rackspace',                                  :rackspace_username  =>  USERNAME,                                :rackspace_api_key    =>  API_KEY                            }  
  56. 56. DNS Requests >>  dns_service.requests   =>  [:callback,  :list_domains,     :list_domain_details,  :modify_domain,  :create_do mains,  :remove_domain,  :remove_domains,  :list_su bdomains,  :list_records,  :list_record_details,  : modify_record,  :remove_record,  :remove_records,   :add_records]    
  57. 57. List Domains >>  r  =  service.list_domains   #<Excon::Response:0x007fdf1ea0f7d0   @data={:body=>{"domains"=>[{"name"=>"bespin-­‐ mining.com",  "id"=>3753036,  "accountId"=>772045,   "emailAddress"=>"darth@empire.com",   "updated"=>"2013-­‐06-­‐17T15:52:29.000+0000",   "created"=>"2013-­‐06-­‐17T15:52:29.000+0000"},..]}}   @headers={"Content-­‐Type"=>"application/json",   "Via"=>"1.1  Repose  (Repose/2.6.11)",  "x-­‐api-­‐ version"=>"1.0.25",  "Content-­‐Length"=>"1509",   "Date"=>"Fri,  05  Jul  2013  18:43:12  GMT",   "Server"=>"Jetty(8.0.y.z-­‐SNAPSHOT)"},  @status=200,   @remote_ip="50.56.3.32">  
  58. 58. List Domains >>  r  =  service.list_domains   #<Excon::Response:0x007fdf1ea0f7d0   @data={:body=>{"domains"=>[{"name"=>"bespin-­‐ mining.com",  "id"=>3753036,  "accountId"=>772045,   "emailAddress"=>"darth@empire.com",   "updated"=>"2013-­‐06-­‐17T15:52:29.000+0000",   "created"=>"2013-­‐06-­‐17T15:52:29.000+0000"},..]}}   @headers={"Content-­‐Type"=>"application/json",   "Via"=>"1.1  Repose  (Repose/2.6.11)",  "x-­‐api-­‐ version"=>"1.0.25",  "Content-­‐Length"=>"1509",   "Date"=>"Fri,  05  Jul  2013  18:43:12  GMT",   "Server"=>"Jetty(8.0.y.z-­‐SNAPSHOT)"},  @status=200,   @remote_ip="50.56.3.32">  
  59. 59. List Domains >>  r  =  service.list_domains   #<Excon::Response:0x007fdf1ea0f7d0   @data={:body=>{"domains"=>[{"name"=>"bespin-­‐ mining.com",  "id"=>3753036,  "accountId"=>772045,   "emailAddress"=>"darth@empire.com",   "updated"=>"2013-­‐06-­‐17T15:52:29.000+0000",   "created"=>"2013-­‐06-­‐17T15:52:29.000+0000"},..]}}   @headers={"Content-­‐Type"=>"application/json",   "Via"=>"1.1  Repose  (Repose/2.6.11)",  "x-­‐api-­‐ version"=>"1.0.25",  "Content-­‐Length"=>"1509",   "Date"=>"Fri,  05  Jul  2013  18:43:12  GMT",   "Server"=>"Jetty(8.0.y.z-­‐SNAPSHOT)"},  @status=200,   @remote_ip="50.56.3.32">  
  60. 60. List Domains >>  r  =  service.list_domains   #<Excon::Response:0x007fdf1ea0f7d0   @data={:body=>{"domains"=>[{"name"=>"bespin-­‐ mining.com",  "id"=>3753036,  "accountId"=>772045,   "emailAddress"=>"darth@empire.com",   "updated"=>"2013-­‐06-­‐17T15:52:29.000+0000",   "created"=>"2013-­‐06-­‐17T15:52:29.000+0000"},..]}}   @headers={"Content-­‐Type"=>"application/json",   "Via"=>"1.1  Repose  (Repose/2.6.11)",  "x-­‐api-­‐ version"=>"1.0.25",  "Content-­‐Length"=>"1509",   "Date"=>"Fri,  05  Jul  2013  18:43:12  GMT",   "Server"=>"Jetty(8.0.y.z-­‐SNAPSHOT)"},  @status=200,   @remote_ip="50.56.3.32">  
  61. 61. Excon::Response >>  domain  =  r.body["domains"].find  do  |h|        h["name"]  ==  "bespin-­‐mining.com"   end   =>  {"name"=>"bespin-­‐mining.com",  "id"=>3753036,   "accountId"=>772045,   "emailAddress"=>"darth@empire.com",   "updated"=>"2013-­‐07-­‐05T19:07:42.000+0000",   "created"=>"2013-­‐06-­‐17T15:52:29.000+0000"}     >>  r.status   =>      200
  62. 62. Adding A Record >>  vip  =  lb.virtual_ips.find  {|ip|                        ip.ip_version  ==  "IPV4"                    }   >>  service.add_records  domain[“id”],  [{    :name  =>  'bespin-­‐mining.com',      :type  =>  'A',      :data  =>  vip.address,      :ttl  =>  600   }]
  63. 63. Load Balancer VMVM DNS bespin-mining.com
  64. 64. Fog deep dive
  65. 65. Retrieve Image service.images.get  "23cebbc9-­‐3219-­‐4a27-­‐9210-­‐d63e1af7181b"  
  66. 66. module  Fog      module  Compute          class  RackspaceV2              class  Images  <  Fog::Collection   def  get(image_id)                      data  =  service.get_image(image_id).body['image']                      new(data)                  rescue  Fog::Compute::RackspaceV2::NotFound                      nil                  end              end          end      end   end  
  67. 67. module  Fog      module  Compute          class  RackspaceV2              class  Images  <  Fog::Collection   def  get(image_id)                      data  =  service.get_image(image_id).body['image']                      new(data)                  rescue  Fog::Compute::RackspaceV2::NotFound                      nil                  end              end          end      end   end  
  68. 68. module  Fog      module  Compute          class  RackspaceV2              class  Real                def  get_image(image_id)                    request(                      :expects  =>  [200,  203],                      :method  =>  'GET',                      :path  =>  "images/#{image_id}"                    )                  end          end      end   end  
  69. 69. module  Fog      module  Compute          class  RackspaceV2              class  Real                def  get_image(image_id)                    request(                      :expects  =>  [200,  203],                      :method  =>  'GET',                      :path  =>  "images/#{image_id}"                    )                  end          end      end   end  
  70. 70. module  Fog      module  Compute          class  RackspaceV2              class  Real                def  get_image(image_id)                    request(                      :expects  =>  [200,  203],                      :method  =>  'GET',                      :path  =>  "images/#{image_id}"                    )                  end          end      end   end  
  71. 71. module  Fog      module  Compute          class  RackspaceV2              class  Real                def  get_image(image_id)                    request(                      :expects  =>  [200,  203],                      :method  =>  'GET',                      :path  =>  "images/#{image_id}"                    )                  end          end      end   end  
  72. 72. GET https://ord.servers.api.rackspacecloud.com:443/v2/5555/ images/23cebbc9-3219-4a27-9210-d63e1af7181b HTTP/1.1 Content-Type: application/json Accept: application/json X-Auth-Token: abc41dc54e594e9c8fb73b89b1b79142 Host: ord.servers.api.rackspacecloud.com:443
  73. 73. GET https://ord.servers.api.rackspacecloud.com:443/v2/5555/ images/23cebbc9-3219-4a27-9210-d63e1af7181b HTTP/1.1 Content-Type: application/json Accept: application/json X-Auth-Token: abc41dc54e594e9c8fb73b89b1b79142 Host: ord.servers.api.rackspacecloud.com:443
  74. 74. GET https://ord.servers.api.rackspacecloud.com:443/v2/5555/ images/23cebbc9-3219-4a27-9210-d63e1af7181b HTTP/1.1 Content-Type: application/json Accept: application/json X-Auth-Token: abc41dc54e594e9c8fb73b89b1b79142 Host: ord.servers.api.rackspacecloud.com:443
  75. 75. GET https://ord.servers.api.rackspacecloud.com:443/v2/5555/ images/23cebbc9-3219-4a27-9210-d63e1af7181b HTTP/1.1 Content-Type: application/json Accept: application/json X-Auth-Token: abc41dc54e594e9c8fb73b89b1b79142 Host: ord.servers.api.rackspacecloud.com:443
  76. 76. GET https://ord.servers.api.rackspacecloud.com:443/v2/5555/ images/23cebbc9-3219-4a27-9210-d63e1af7181b HTTP/1.1 Content-Type: application/json Accept: application/json X-Auth-Token: abc41dc54e594e9c8fb73b89b1b79142 Host: ord.servers.api.rackspacecloud.com:443
  77. 77. GET https://ord.servers.api.rackspacecloud.com:443/v2/5555/ images/23cebbc9-3219-4a27-9210-d63e1af7181b HTTP/1.1 Content-Type: application/json Accept: application/json X-Auth-Token: abc41dc54e594e9c8fb73b89b1b79142 Host: ord.servers.api.rackspacecloud.com:443
  78. 78. EXCON_DEBUG=true
  79. 79. Fog.mock! Testing
  80. 80. RACKSPACE® HOSTING | WWW.RACKSPACE.COM http://developer.rackspace.com/#ruby @krames Questions?
  81. 81. Images tule fog, marya, CC BY-SA 2.0 Clouds, Daniel Boyd, CC BY 2.0 Metroid II: Return of Samus, Michel Ngilen, CC BY-SA 2.0 Lego Mindstorms Kit, Marlon J. Manrique, CC BY 2.0 CD,Visual Pharm, CC BY-SA 2.0 Public Bikes, Richard Masoner / Cyclelicious, CC BY 2.0 PRIVATE, Rupert Ganzer, CC BY 2.0 Hybrid Sorry We Are Not Open, Alan Levine, CC BY 2.0 We are, e1ther, CC BY 2.0
  82. 82. Images (cont) Yipwm_1b, Greg Goebel, CC BY-SA 2.0 Pause Button, GreenLantern33, CC BY-SA 2.0 3..., Cristiano Betta, CC BY-SA 2.0

×