Advertisement
alvise72

Untitled

Jun 3rd, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. # Corso di formazione Padova - Hands on
  2.  
  3. # PARTE 1 - BASIC
  4. # questa parte e' gia' stata fatta attraverso la dashobard)
  5. # Source credentials file
  6. source userXX-openrc.sh
  7.  
  8. # Create private network
  9. neutron net-create private_net
  10.  
  11. # Associate subnet
  12. neutron subnet-create --name private_subnet private_net 10.0.1.0/24
  13.  
  14. # Check private network and subnet
  15. neutron net-list
  16. neutron subnet-list
  17.  
  18. # create router
  19. neutron router-create myrouter
  20.  
  21. # uplink router to the public internet (set gateway)
  22. neutron router-gateway-set myrouter Esterna
  23.  
  24. # uplink subnet to router
  25. neutron router-interface-add myrouter private_subnet
  26.  
  27. # create security profile for jump host
  28. neutron security-group-create jumphost
  29.  
  30. # Add rule to allow icmp in
  31. neutron security-group-rule-create --protocol icmp jumphost
  32.  
  33. # Add rule to allow ssh in
  34. neutron security-group-rule-create --protocol tcp --port-range-min 22 --port-range-max 22 jumphost
  35.  
  36. # Launch jump host:
  37. nova boot --image CentOS --flavor 1 jumphost --security_groups jumphost
  38.  
  39.  
  40. ############################################
  41. # PARTE 2 - ADVANCED
  42. # Source credentials file
  43. source userXX-openrc.sh
  44.  
  45. # Check private network, subnet, running vm
  46. neutron net-list
  47. neutron subnet-list
  48. neutron router-list
  49. nova list
  50.  
  51. # Determine port-id attached to jumphost
  52. neutron port-list --device_id=<instance_id>
  53.  
  54. # create floatingip
  55. neutron floatingip-create Esterna --port-id <port-id>
  56.  
  57. # test ping/ssh
  58. nova list
  59. ping -c 3 147.162.159.xxx
  60. ssh [email protected] #password is: corso-cloud-2014
  61.  
  62. # create web security group
  63. neutron security-group-create web
  64.  
  65. # allow tcp 80 in
  66. neutron security-group-rule-create --protocol TCP --port-range-min 80 --port-range-max 80 web
  67.  
  68. # allow ssh from members of jumphost
  69. neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 22 --port-range-max 22 --remote-group-id jumphost web
  70.  
  71. # boot two webservers
  72. nova boot --image CentOS --flavor 1 webserver1 --security_groups web --nic net-id=<private_network_ID>
  73. nova boot --image CentOS --flavor 1 webserver2 --security_groups web --nic net-id=<private_network_ID>
  74. nova list
  75.  
  76. # ssh to jumphost (floating-ip = 147.162.159.xxx)
  77. ssh root@<floating-ip> #password is: corso-cloud-2014
  78.  
  79. # ssh to webserver1
  80. ssh 10.0.1.x #password is: corso-cloud-2014
  81.  
  82. # start dummy webserver
  83. echo "Welcome to $HOSTNAME" >/var/www/html/index.html
  84. /etc/init.d/httpd start
  85. chkconfig httpd on
  86. curl 10.0.1.x
  87.  
  88. # exit from webserver1 to jumphost
  89. exit
  90.  
  91. # repeat for webserver2
  92.  
  93. # curl <webserver1-ip>
  94. webserver1
  95.  
  96. # curl <webserver2-ip>
  97. webserver2
  98.  
  99. # exit from jumphost
  100. exit
  101.  
  102. # create loadbalanacer pool
  103. neutron subnet-list
  104. neutron lb-pool-create --lb-method ROUND_ROBIN --name mypool --protocol HTTP --subnet-id <private_subnet_ID>
  105.  
  106. # Add webservers as memebers
  107. neutron lb-member-create --address <webserver_1_ip> --protocol-port 80 mypool
  108. neutron lb-member-create --address <webserver_2_ip> --protocol-port 80 mypool
  109.  
  110. # create health monitor
  111. neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
  112.  
  113. # associate with pool
  114. neutron lb-healthmonitor-associate <heath-monitor-id> mypool
  115.  
  116. # create vip for loadbalaner
  117. neutron lb-vip-create --name myvip --protocol-port 80 --protocol HTTP --subnet-id <private_subnet_ID> mypool
  118.  
  119. # associate floatingip to vip
  120. neutron floatingip-create Esterna --port-id <port_ID da output comando precedente>
  121.  
  122. # requests are now loadbalanced over vip ip:
  123. curl <vip-floatingip>
  124.  
  125. # test loadbalancer timeout
  126. nova stop webserver1
  127. curl <vip-floatingip> #only returns webserver2, after a while
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement