You are on page 1of 13

OpenStack Pike

2017/09/03

Travaux de synthèse : Taylor VOLI

Volet 4
2

OpenStack Pike : Configure Networking


2017/09/03

Configure Networking for Virtual Machine Instances.


Configure basic settings first for Neutron Services like All in One Settings or Neutron Nodes
like here.
For example, configure FLAT type of provider networking on here.
The Node has 2 network interfaces like follows.
eth0|10.0.0.30
+-----------+-----------+
| [ Control Node ] |
| |
| MariaDB RabbitMQ |
| Memcached httpd |eth1
| Keystone Glance +------
| Nova API,Compute |
| Neutron Server |
| L2,L3,Metadata Agent |
+-----------------------+

[1] Configure Neutron services.


# add bridge

[root@dlp ~(keystone)]# ovs-vsctl add-br br-eth1

# add eth1 to the port of the bridge above

[root@dlp ~(keystone)]# ovs-vsctl add-port br-eth1 eth1

[root@dlp ~(keystone)]# vi /etc/neutron/plugins/ml2/ml2_conf.ini


# line 166: add

[ml2_type_flat]
flat_networks = physnet1
[root@dlp ~(keystone)]# vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# line 180: add

[ovs]
bridge_mappings = physnet1:br-eth1
[root@dlp ~(keystone)]# systemctl restart neutron-openvswitch-agent

[2] Create virtual network.


[root@dlp ~(keystone)]# projectID=`openstack project list | grep service | awk '{print $2}'`
# create network named [sharednet1]

2
3

[root@dlp ~(keystone)]# openstack network create --project $projectID \


--share --provider-network-type flat --provider-physical-network physnet1 sharednet1

+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2017-09-04T06:39:09Z |
| description | |
| dns_domain | None |
| id | fdb1468f-b479-4cbc-b82e-582719536cbc |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | sharednet1 |
| port_security_enabled | True |
| project_id | c9ab6e9feb4d444c8f637fcfe7a67305 |
| provider:network_type | flat |
| provider:physical_network | physnet1 |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 2 |
| router:external | Internal |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2017-09-04T06:39:09Z |
+---------------------------+--------------------------------------+

# create subnet [10.0.0.0/24] in [sharednet1]

[root@dlp ~(keystone)]# openstack subnet create subnet1 --network sharednet1 \


--project $projectID --subnet-range 10.0.0.0/24 \
--allocation-pool start=10.0.0.200,end=10.0.0.254 \
--gateway 10.0.0.1 --dns-nameserver 10.0.0.10

+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| allocation_pools | 10.0.0.200-10.0.0.254 |
| cidr | 10.0.0.0/24 |
| created_at | 2017-09-04T06:39:33Z |
| description | |
| dns_nameservers | 10.0.0.10 |
| enable_dhcp | True |
| gateway_ip | 10.0.0.1 |

3
4

| host_routes | |
| id | bd84f1db-6f15-4994-9f1c-54bbe9c79152 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | subnet1 |
| network_id | fdb1468f-b479-4cbc-b82e-582719536cbc |
| project_id | c9ab6e9feb4d444c8f637fcfe7a67305 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2017-09-04T06:39:33Z |
| use_default_subnet_pool | None |
+-------------------------+--------------------------------------+

# confirm settings

[root@dlp ~(keystone)]# openstack network list

+--------------------------------------+------------+-------------------------------
-------+
| ID | Name | Subnets
|
+--------------------------------------+------------+-------------------------------
-------+
| fdb1468f-b479-4cbc-b82e-582719536cbc | sharednet1 | bd84f1db-6f15-4994-9f1c-
54bbe9c79152 |
+--------------------------------------+------------+-------------------------------
-------+

[root@dlp ~(keystone)]# openstack subnet list

+--------------------------------------+---------+----------------------------------
----+-------------+
| ID | Name | Network
| Subnet |
+--------------------------------------+---------+----------------------------------
----+-------------+
| bd84f1db-6f15-4994-9f1c-54bbe9c79152 | subnet1 | fdb1468f-b479-4cbc-b82e-
582719536cbc | 10.0.0.0/24 |
+--------------------------------------+---------+----------------------------------
----+-------------+

4
5

OpenStack Pike : Run Instances


2017/09/03

Create and Start Virtual Machine Instance.


Create a flavor (cpu, memory, disk (and others) specification) and create an instance and
[1]
boot it.
# create a flavor

[root@dlp ~(keystone)]#
openstack flavor create --id 0 --vcpus 1 --ram 2048 --disk 10 m1.small

+----------------------------+----------+
| Field | Value |
+----------------------------+----------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 10 |
| id | 0 |
| name | m1.small |
| os-flavor-access:is_public | True |
| properties | |
| ram | 2048 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+----------+

[root@dlp ~(keystone)]#
openstack flavor list

+----+----------+------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+----------+------+------+-----------+-------+-----------+
| 0 | m1.small | 2048 | 10 | 0 | 1 | True |
+----+----------+------+------+-----------+-------+-----------+

# show the list of images

[root@dlp ~(keystone)]#
openstack image list

+--------------------------------------+---------+--------+
| ID | Name | Status |
+--------------------------------------+---------+--------+
| 68132026-60aa-4afe-8976-398b0482cfd6 | CentOS7 | active |
+--------------------------------------+---------+--------+

# show the list of network

5
6

[root@dlp ~(keystone)]#
openstack network list

+--------------------------------------+------------+-------------------------------
-------+
| ID | Name | Subnets
|
+--------------------------------------+------------+-------------------------------
-------+
| fdb1468f-b479-4cbc-b82e-582719536cbc | sharednet1 | bd84f1db-6f15-4994-9f1c-
54bbe9c79152 |
+--------------------------------------+------------+-------------------------------
-------+

[root@dlp ~(keystone)]#
netID=`openstack network list | grep sharednet1 | awk '{ print $2 }'`

# create a keypair

[root@dlp ~(keystone)]#
ssh-keygen -q -N ""

Enter file in which to save the key (/root/.ssh/id_rsa):


# add the public key

[root@dlp ~(keystone)]#
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey

+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | b3:d6:64:1a:6f:4e:14:63:88:76:15:a4:bd:af:a6:34 |
| name | mykey |
| user_id | 09d8dfa20e0f40eaae448d369943b195 |
+-------------+-------------------------------------------------+

[root@dlp ~(keystone)]#
openstack keypair list

+-------+-------------------------------------------------+
| Name | Fingerprint |
+-------+-------------------------------------------------+
| mykey | b3:d6:64:1a:6f:4e:14:63:88:76:15:a4:bd:af:a6:34 |
+-------+-------------------------------------------------+

# create and boot an instance with the key

[root@dlp ~(keystone)]#

6
7

openstack server create --flavor m1.small --image CentOS7 --security-group default --nic net-
id=$netID --key-name mykey CentOS_7
+-------------------------------------+---------------------------------------------
---+
| Field | Value
|
+-------------------------------------+---------------------------------------------
---+
| OS-DCF:diskConfig | MANUAL
|
| OS-EXT-AZ:availability_zone |
|
| OS-EXT-SRV-ATTR:host | None
|
| OS-EXT-SRV-ATTR:hypervisor_hostname | None
|
| OS-EXT-SRV-ATTR:instance_name |
|
| OS-EXT-STS:power_state | NOSTATE
|
| OS-EXT-STS:task_state | scheduling
|
| OS-EXT-STS:vm_state | building
|
| OS-SRV-USG:launched_at | None
|
| OS-SRV-USG:terminated_at | None
|
| accessIPv4 |
|
| accessIPv6 |
|
| addresses |
|
| adminPass | JQF2YtHUDhh3
|
| config_drive |
|
| created | 2017-09-04T08:19:03Z
|
| flavor | m1.small (0)
|
| hostId |
|
| id | 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2
|
| image | CentOS7 (68132026-60aa-4afe-8976-
398b0482cfd6) |
| key_name | mykey
|
| name | CentOS_7
|
| progress | 0
|

7
8

| project_id | 09158bee8c6441519bf3a3743d936566
|
| properties |
|
| security_groups | name='b8b67ada-379b-4c5f-8ac8-899e943dbbe0'
|
| status | BUILD
|
| updated | 2017-09-04T08:19:03Z
|
| user_id | 09d8dfa20e0f40eaae448d369943b195
|
| volumes_attached |
|
+-------------------------------------+---------------------------------------------
---+

# show status ([BUILD] status is shown when building instance)

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| ID | Name | Status | Networks |
Image | Flavor |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | BUILD | sharednet1=10.0.0.202 |
CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+

# when starting noramlly, the status turns to [ACTIVE]

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| ID | Name | Status | Networks |
Image | Flavor |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 |
CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
[2] Configure security settings like follows to access with SSH and ICMP.
# permit ICMP

8
9

[root@dlp ~(keystone)]#
openstack security group rule create --protocol icmp --ingress default

+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2017-09-04T08:20:44Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 6ef8160e-fd04-45cd-a569-93f068d0635f |
| name | None |
| port_range_max | None |
| port_range_min | None |
| project_id | 09158bee8c6441519bf3a3743d936566 |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | b8b67ada-379b-4c5f-8ac8-899e943dbbe0 |
| updated_at | 2017-09-04T08:20:44Z |
+-------------------+--------------------------------------+

# permit SSH

[root@dlp ~(keystone)]#
openstack security group rule create --protocol tcp --dst-port 22:22 default

+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2017-09-04T08:21:04Z |
| description | |
| direction | ingress |
| ether_type | IPv4 |
| id | 3ec427f4-9f9f-4ece-aced-1b4b2a4e14a7 |
| name | None |
| port_range_max | 22 |
| port_range_min | 22 |
| project_id | 09158bee8c6441519bf3a3743d936566 |
| protocol | tcp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 0 |
| security_group_id | b8b67ada-379b-4c5f-8ac8-899e943dbbe0 |
| updated_at | 2017-09-04T08:21:04Z |
+-------------------+--------------------------------------+

[root@dlp ~(keystone)]#
openstack security group rule list

9
10

+--------------+-------------+-----------+------------+-----------------------------
---------+-------------------+
| ID | IP Protocol | IP Range | Port Range | Remote Security Group
| Security Group |
+--------------+-------------+-----------+------------+-----------------------------
---------+-------------------+
| 04544fda-... | None | None | | None
| b8b67ada-379b-... |
| 0c1f30a4-... | None | None | | b8b67ada-379b-4c5f-8ac8-
899e943dbbe0 | b8b67ada-379b-... |
| 2c70e734-... | None | None | | None
| b8b67ada-379b-... |
| 3ec427f4-... | tcp | 0.0.0.0/0 | 22:22 | None
| b8b67ada-379b-... |
| 6ef8160e-... | icmp | 0.0.0.0/0 | | None
| b8b67ada-379b-... |
| a3745804-... | None | None | | b8b67ada-379b-4c5f-8ac8-
899e943dbbe0 | b8b67ada-379b-... |
+--------------+-------------+-----------+------------+-----------------------------
---------+-------------------+
[3] Login to instance with SSH.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| ID | Name | Status | Networks |
Image | Flavor |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 |
CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+

[root@dlp ~(keystone)]#
ping 10.0.0.202 -c3

PING 10.0.0.202 (10.0.0.202) 56(84) bytes of data.


64 bytes from 10.0.0.202: icmp_seq=1 ttl=64 time=3.13 ms
64 bytes from 10.0.0.202: icmp_seq=2 ttl=64 time=0.833 ms
64 bytes from 10.0.0.202: icmp_seq=3 ttl=64 time=0.831 ms

--- 10.0.0.202 ping statistics ---


3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.831/1.600/3.136/1.086 ms

[root@dlp ~(keystone)]#
ssh centos@10.0.0.202
The authenticity of host '10.0.0.202 (10.0.0.202)' can't be established.
ECDSA key fingerprint is 94:11:48:02:fa:62:ff:9c:c4:75:8f:eb:16:62:a9:ff.
Are you sure you want to continue connecting (yes/no)? yes

10
11

Warning: Permanently added '10.0.0.202' (ECDSA) to the list of known hosts.


[centos@centos-7 ~]$
# just logined

If you'd like to stop an instance, it's also possible to control with openstack command like
[4]
follows.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| ID | Name | Status | Networks |
Image | Flavor |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 |
CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+

# stop instance

[root@dlp ~(keystone)]#
openstack server stop CentOS_7

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+---------+-----------------------
+---------+----------+
| ID | Name | Status | Networks
| Image | Flavor |
+--------------------------------------+----------+---------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | SHUTOFF | sharednet1=10.0.0.202
| CentOS7 | m1.small |
+--------------------------------------+----------+---------+-----------------------
+---------+----------+

# start instance

[root@dlp ~(keystone)]#
openstack server start CentOS_7

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------
+---------+----------+

11
12

| ID | Name | Status | Networks |


Image | Flavor |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 |
CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
[5] It's possible to access with Web browser to get VNC console.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------
+------------+
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| ID | Name | Status | Networks |
Image | Flavor |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 |
CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------
+---------+----------+

[root@dlp ~(keystone)]#
openstack console url show CentOS_7

+-------+---------------------------------------------------------------------------
-----+
| Field | Value
|
+-------+---------------------------------------------------------------------------
-----+
| type | novnc
|
| url | http://10.0.0.30:6080/vnc_auto.html?token=f5652854-8cce-4a0f-b22c-
7bd384d03d20 |
+-------+---------------------------------------------------------------------------
-----+
[6] Access to the URL which was displayed by the command above.

12
13

13

You might also like