Thursday, May 17, 2018

.::: Create Tenant (Project, User, Keypair, Network, Floating, upload Image, Flavors) & launch Instance In Openstack Using CLI :::.

Continue from after posting install openstack packstack on centos7. this tutorial create instance detail using CLI(Command Line Interface)

1. Create Project & User
# source keystonerc_admin
# openstack project create --description teguht-project-des teguht-project
# openstack user create --project teguht-project --password teguht --email teguh.triharto@microsoft.com teguht
# openstack project list 
# openstack project show teguht-project





2. Create Keystone for teguht<new_user> & keypair
# cp keystonerc_admin keystonerc_teguht
# cat keystonerc_teguht
unset OS_SERVICE_TOKEN
    export OS_USERNAME=teguht
    export OS_PASSWORD=teguht
    export OS_AUTH_URL=http://172.30.1.111:5000/v2.0
    export PS1='[\u@\h \W(keystone_teguht)]\$ '
   
export OS_TENANT_NAME=teguht-project
export OS_REGION_NAME=RegionOne
#
sample output
[root@openstack ~(keystone_admin)]# cat /root/keystonerc_teguht
unset OS_SERVICE_TOKEN
    export OS_USERNAME=teguht
#    export OS_PASSWORD=1d0c29fb2f9a4a6f
export OS_PASSWORD=teguht
    export OS_AUTH_URL=http://192.168.5.111:5000/v2.0
    export PS1='[\u@\h \W(keystone_teguht)]\$ '
   
export OS_TENANT_NAME=teguht-project
export OS_REGION_NAME=RegionOne
   
You have mail in /var/spool/mail/root
[root@openstack ~(keystone_admin)]# 


3. Create keypair
# source keystonerc_teguht
# openstack keypair create teguht-keypair > /root/teguht-keypair.pem
# chmod 600 /root/teguht-keypair.pem
# openstack keypair list
# openstack keypair show teguht-keypair


4. Create security
# source keystonerc_teguht
# openstack security group create teguht-security
# openstack security group rule create --protocol tcp --dst-port 22 teguht-security
# openstack security group rule create --protocol icmp teguht-security
# openstack security group list
# openstack security group show teguht-security



5. Create Private Network
# source /root/keystonerc_teguht
# openstack network create priv_net
# openstack subnet create --dhcp --subnet-range 2.2.2.0/24 --gateway 2.2.2.1 --allocation-pool start=2.2.2.10,end=2.2.2.30 --dns-nameserver 8.8.8.8 --network priv_net priv_subnet

# source /root/keystonerc_admin
# openstack network  show priv_net
# openstack network  set --share priv_net
# openstack network  show priv_net

# source /root/keystonerc_teguht
# openstack subnet list
# openstack subnet show priv_subnet




6. Create Public Network
# source /root/keystonerc_teguht
# openstack network create pub_net
# openstack subnet create --no-dhcp --subnet-range 172.30.1.0/24 --allocation-pool start=172.30.1.10,end=172.30.1.30 --dns-nameserver 172.30.2.22 --network pub_net pub_subnet

# source /root/keystonerc_admin
# openstack network show pub_net
# openstack network set --share --external pub_net
# openstack network show pub_net

# source /root/keystonerc_teguht
# openstack subnet list
# openstack subnet show pub_subnet




https://www.tuxfixer.com/openstack-how-to-manually-delete-orphaned-neutron-port/#more-1206

use neutron
delete from ports where id='a476470a-6d36-4dfc-bb57-6f53438f0aa5';
http://docs.metacloud.com/latest/user-guide/cli-deleting-network-resources/

7. Create Router
# source /root/keystonerc_teguht
# openstack router create router-teguht
# neutron router-gateway-set router-teguht pub_net
# openstack router add subnet router-teguht priv_subnet
# openstack router list
# openstack router show router-teguht
# neutron port-list





8. Create Floating IP
# source /root/keystonerc_teguht
# openstack floating ip create pub_net
# openstack floating ip create pub_net
# openstack floating ip list
# openstack floating ip show 172.30.1.11
# openstack floating ip show 172.30.1.15


9. Uploading Image
# source /root/keystonerc_admin
# openstack image create --disk-format qcow2 --file cirros-0.4.0-x86_64-disk.img --public cirros-Image
or
# openstack image create --disk-format qcow2 --file cirros-0.4.0-x86_64-disk.img --public cirros-Image
# openstack image list
# openstack image show cirros-Image
 


10. Create Flavors
# source /root/keystonerc_admin
# openstack flavor create --id 6 --ram 1000 --disk 2 --vcpus 1 m1.testflavor
# openstack flavor list
# openstack flavor show m1.testflavor


11. create instance as example 2 instance(server)
# openstack server create --nic net-id=priv_net --security-group teguht-security --image cirros-Image --flavor m1.testflavor --key-name teguht-keypair --wait teguht-custom01
# openstack server create --nic net-id=priv_net --security-group teguht-security --image cirros-Image --flavor m1.testflavor --key-name teguht-keypair --wait teguht-custom02
# openstack server list
# openstack server show teguht-custom01
# openstack server show teguht-custom02


12. add server floating ip
# source /root/keystonerc_teguht
# openstack server add floating ip teguht-custom01 172.30.1.15
# openstack server add floating ip teguht-custom02 172.30.1.11

13. Open console Instance 1(teguht-custom01 )and test ping IP
# hostname
# ping -c1 2.2.2.11
# ping -c1 172.30.1.11
# ping -c1 2.2.2.14
# ping -c1 172.30.1.15
# ping -c1 172.30.2.24
# ping -c1 8.8.8.8


[root@openstack ~(keystone_teguht)]# ssh cirros@172.30.1.15
The authenticity of host '172.30.1.15 (172.30.1.15)' can't be established.
ECDSA key fingerprint is SHA256:zMTpSeErWRSVdHlJl936TYuMY8sUwI2yxhD6HR8SDiI.
ECDSA key fingerprint is MD5:d0:d8:77:2d:27:0f:0f:98:c8:7f:cd:d8:0e:81:46:cc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.30.1.15' (ECDSA) to the list of known hosts.
cirros@172.30.1.15's password:
$ hostname
teguht-custom01
$ ping -c1 2.2.2.11
PING 2.2.2.11 (2.2.2.11): 56 data bytes
64 bytes from 2.2.2.11: seq=0 ttl=64 time=32.071 ms

--- 2.2.2.11 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 32.071/32.071/32.071 ms
$ ping -c1 2.2.2.14
PING 2.2.2.14 (2.2.2.14): 56 data bytes
64 bytes from 2.2.2.14: seq=0 ttl=64 time=19.510 ms

--- 2.2.2.14 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 19.510/19.510/19.510 ms
$ ping -c1 172.30.1.11
PING 172.30.1.11 (172.30.1.11): 56 data bytes
64 bytes from 172.30.1.11: seq=0 ttl=63 time=1.728 ms

--- 172.30.1.11 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.728/1.728/1.728 ms
$ ping -c1 172.30.1.15
PING 172.30.1.15 (172.30.1.15): 56 data bytes
64 bytes from 172.30.1.15: seq=0 ttl=63 time=1.902 ms

--- 172.30.1.15 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.902/1.902/1.902 ms
$ ping -c1 172.30.1.24
PING 172.30.1.24 (172.30.1.24): 56 data bytes
64 bytes from 172.30.1.24: seq=0 ttl=125 time=15.278 ms

--- 172.30.1.24 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 15.278/15.278/15.278 ms
$ ping -c1 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=53 time=23.257 ms

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 23.257/23.257/23.257 ms
$ exitConnection to 172.30.1.15 closed.
You have mail in /var/spool/mail/root
[root@openstack ~(keystone_teguht)]# 

14. Open console Instance 2(teguht-custom02 )and test ping IP
# hostname
# ping -c1 2.2.2.11
# ping -c1 172.30.1.11
# ping -c1 2.2.2.14
# ping -c1 172.30.1.15
# ping -c1 172.30.2.24
# ping -c1 8.8.8.8

[root@openstack ~(keystone_teguht)]# ssh cirros@172.30.1.11
The authenticity of host '172.30.1.11 (172.30.1.11)' can't be established.
ECDSA key fingerprint is SHA256:cTStLpL34qFr6lhsKdgQ2gnXgAmY+jVogb+cFEIGoLA.
ECDSA key fingerprint is MD5:ff:6b:71:41:ab:cc:77:88:7e:30:e4:89:84:a6:c7:e5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.30.1.11' (ECDSA) to the list of known hosts.
cirros@172.30.1.11's password:
$ hostname
teguht-custom02
$ ping -c1 2.2.2.11
PING 2.2.2.11 (2.2.2.11): 56 data bytes
64 bytes from 2.2.2.11: seq=0 ttl=64 time=65.375 ms

--- 2.2.2.11 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 65.375/65.375/65.375 ms
$ ping -c1 2.2.2.14
PING 2.2.2.14 (2.2.2.14): 56 data bytes
64 bytes from 2.2.2.14: seq=0 ttl=64 time=76.163 ms

--- 2.2.2.14 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 76.163/76.163/76.163 ms
$ ping -c1 172.30.1.11
PING 172.30.1.11 (172.30.1.11): 56 data bytes
64 bytes from 172.30.1.11: seq=0 ttl=63 time=87.308 ms

--- 172.30.1.11 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 87.308/87.308/87.308 ms
$ ping -c1 172.30.1.15
PING 172.30.1.15 (172.30.1.15): 56 data bytes
64 bytes from 172.30.1.15: seq=0 ttl=63 time=71.663 ms

--- 172.30.1.15 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 71.663/71.663/71.663 ms
$ ping -c1 172.30.1.24
PING 172.30.1.24 (172.30.1.24): 56 data bytes
64 bytes from 172.30.1.24: seq=0 ttl=125 time=44.970 ms

--- 172.30.1.24 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 44.970/44.970/44.970 ms
$ cat /etc/hosts
127.0.0.1    localhost
127.0.1.1    cirros
$ exit
Connection to 172.30.1.11 closed.
You have mail in /var/spool/mail/root
[root@openstack ~(keystone_teguht)]#

15. Check Network Topology for your project




16. Detail lab as

17. for detail log. go to Log OutputCreate Tenant Project, User, Keypair, Network, Floating, upload Image, Flavors, Instance In Openstack Using CLI

No comments:

Post a Comment

Popular Posts