Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Corso di formazione Padova - Hands on
- # PARTE 1 - BASIC
- # questa parte e' gia' stata fatta attraverso la dashobard)
- # Source credentials file
- source userXX-openrc.sh
- # Create private network
- neutron net-create private_net
- # Associate subnet
- neutron subnet-create --name private_subnet private_net 10.0.1.0/24
- # Check private network and subnet
- neutron net-list
- neutron subnet-list
- # create router
- neutron router-create myrouter
- # uplink router to the public internet (set gateway)
- neutron router-gateway-set myrouter Esterna
- # uplink subnet to router
- neutron router-interface-add myrouter private_subnet
- # create security profile for jump host
- neutron security-group-create jumphost
- # Add rule to allow icmp in
- neutron security-group-rule-create --protocol icmp jumphost
- # Add rule to allow ssh in
- neutron security-group-rule-create --protocol tcp --port-range-min 22 --port-range-max 22 jumphost
- # Launch jump host:
- nova boot --image CentOS --flavor 1 jumphost --security_groups jumphost
- ############################################
- # PARTE 2 - ADVANCED
- # Source credentials file
- source userXX-openrc.sh
- # Check private network, subnet, running vm
- neutron net-list
- neutron subnet-list
- neutron router-list
- nova list
- # Determine port-id attached to jumphost
- neutron port-list --device_id=<instance_id>
- # create floatingip
- neutron floatingip-create Esterna --port-id <port-id>
- # test ping/ssh
- nova list
- ping -c 3 147.162.159.xxx
- ssh [email protected] #password is: corso-cloud-2014
- # create web security group
- neutron security-group-create web
- # allow tcp 80 in
- neutron security-group-rule-create --protocol TCP --port-range-min 80 --port-range-max 80 web
- # allow ssh from members of jumphost
- neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 22 --port-range-max 22 --remote-group-id jumphost web
- # boot two webservers
- nova boot --image CentOS --flavor 1 webserver1 --security_groups web --nic net-id=<private_network_ID>
- nova boot --image CentOS --flavor 1 webserver2 --security_groups web --nic net-id=<private_network_ID>
- nova list
- # ssh to jumphost (floating-ip = 147.162.159.xxx)
- ssh root@<floating-ip> #password is: corso-cloud-2014
- # ssh to webserver1
- ssh 10.0.1.x #password is: corso-cloud-2014
- # start dummy webserver
- echo "Welcome to $HOSTNAME" >/var/www/html/index.html
- /etc/init.d/httpd start
- chkconfig httpd on
- curl 10.0.1.x
- # exit from webserver1 to jumphost
- exit
- # repeat for webserver2
- # curl <webserver1-ip>
- webserver1
- # curl <webserver2-ip>
- webserver2
- # exit from jumphost
- exit
- # create loadbalanacer pool
- neutron subnet-list
- neutron lb-pool-create --lb-method ROUND_ROBIN --name mypool --protocol HTTP --subnet-id <private_subnet_ID>
- # Add webservers as memebers
- neutron lb-member-create --address <webserver_1_ip> --protocol-port 80 mypool
- neutron lb-member-create --address <webserver_2_ip> --protocol-port 80 mypool
- # create health monitor
- neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
- # associate with pool
- neutron lb-healthmonitor-associate <heath-monitor-id> mypool
- # create vip for loadbalaner
- neutron lb-vip-create --name myvip --protocol-port 80 --protocol HTTP --subnet-id <private_subnet_ID> mypool
- # associate floatingip to vip
- neutron floatingip-create Esterna --port-id <port_ID da output comando precedente>
- # requests are now loadbalanced over vip ip:
- curl <vip-floatingip>
- # test loadbalancer timeout
- nova stop webserver1
- curl <vip-floatingip> #only returns webserver2, after a while
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement