CentOS 8
Sponsored Link

OpenStack Victoria : Create Instances2020/11/17

 
Create and Start Virtual Machine Instance.
[1] Login with a user and create a config for authentication of Keystyone.
The username or password in the config are just the one you added in keystone like here.
Next Create and run an instance.
[cent@dlp ~]$
vi ~/keystonerc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=hiroshima
export OS_USERNAME=serverworld
export OS_PASSWORD=userpassword
export OS_AUTH_URL=http://10.0.0.30:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export PS1='[\u@\h \W(keystone)]\$ '
[cent@dlp ~]$
chmod 600 ~/keystonerc

[cent@dlp ~]$
source ~/keystonerc

[cent@dlp ~(keystone)]$
echo "source ~/keystonerc " >> ~/.bash_profile
# show available [flavor] list

[cent@dlp ~(keystone)]$
openstack flavor list

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

# show available image list

[cent@dlp ~(keystone)]$
openstack image list

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| 8507b98f-3e9d-4ac9-92f9-9ee8d7f69339 | CentOS8 | active |
+--------------------------------------+---------+--------+

# show available network list

[cent@dlp ~(keystone)]$
openstack network list

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| eb98c7ec-2f7c-4904-87e0-b36767f7e102 | sharednet1 | 072580b0-eb8a-4c53-b4f9-687f84c04510 |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

[cent@dlp ~(keystone)]$
openstack security group create secgroup01

+-----------------+---------------------------------------------------------------------------------+
| Field           | Value                                                                           |
+-----------------+---------------------------------------------------------------------------------+
| created_at      | 2020-11-17T02:14:59Z                                                            |
| description     | secgroup01                                                                      |
| id              | dc94fe3a-6faa-4397-a8e9-703f86c687c9                                            |
| name            | secgroup01                                                                      |
| project_id      | 8cc9f93ed89f40e28a610d025462c020                                                |
| revision_number | 1                                                                               |
| rules           | created_at='2020-11-17T02:14:59Z', direction='egress', ethertype='IPv4', id=... |
|                 | created_at='2020-11-17T02:14:59Z', direction='egress', ethertype='IPv6', id=... |
| stateful        | True                                                                            |
| tags            | []                                                                              |
| updated_at      | 2020-11-17T02:14:59Z                                                            |
+-----------------+---------------------------------------------------------------------------------+

[cent@dlp ~(keystone)]$
openstack security group list

+--------------------------------------+------------+------------------------+----------------------------------+------+
| ID                                   | Name       | Description            | Project                          | Tags |
+--------------------------------------+------------+------------------------+----------------------------------+------+
| 31077ae6-f869-4229-a984-705e6fa6a60e | default    | Default security group | 8cc9f93ed89f40e28a610d025462c020 | []   |
| dc94fe3a-6faa-4397-a8e9-703f86c687c9 | secgroup01 | secgroup01             | 8cc9f93ed89f40e28a610d025462c020 | []   |
+--------------------------------------+------------+------------------------+----------------------------------+------+

# create a SSH keypair for connecting to instances

[cent@dlp ~(keystone)]$
ssh-keygen -q -N ""

Enter file in which to save the key (/home/cent/.ssh/id_rsa):
# add public-key

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

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 45:50:e9:03:b8:3a:31:f8:ca:67:83:25:55:3a:2a:44 |
| name        | mykey                                           |
| user_id     | bb4ae84eefc04357987ec43b8e93118c                |
+-------------+-------------------------------------------------+

[cent@dlp ~(keystone)]$
openstack keypair list

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 45:50:e9:03:b8:3a:31:f8:ca:67:83:25:55:3a:2a:44 |
+-------+-------------------------------------------------+

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

# create and boot an instance

[cent@dlp ~(keystone)]$
openstack server create --flavor m1.small --image CentOS8 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS-8
+-----------------------------+------------------------------------------------+
| Field                       | Value                                          |
+-----------------------------+------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                         |
| OS-EXT-AZ:availability_zone |                                                |
| 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                   | mPuLW5KdmkH2                                   |
| config_drive                |                                                |
| created                     | 2020-11-17T02:19:11Z                           |
| flavor                      | m1.small (0)                                   |
| hostId                      |                                                |
| id                          | 24ca61e0-1463-4456-93ca-31c5cc6ba2b5           |
| image                       | CentOS8 (8507b98f-3e9d-4ac9-92f9-9ee8d7f69339) |
| key_name                    | mykey                                          |
| name                        | CentOS-8                                       |
| progress                    | 0                                              |
| project_id                  | 8cc9f93ed89f40e28a610d025462c020               |
| properties                  |                                                |
| security_groups             | name='dc94fe3a-6faa-4397-a8e9-703f86c687c9'    |
| status                      | BUILD                                          |
| updated                     | 2020-11-17T02:19:11Z                           |
| user_id                     | bb4ae84eefc04357987ec43b8e93118c               |
| volumes_attached            |                                                |
+-----------------------------+------------------------------------------------+

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

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+----------+---------+----------+
| ID                                   | Name     | Status | Networks | Image   | Flavor   |
+--------------------------------------+----------+--------+----------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | BUILD  |          | CentOS8 | m1.small |
+--------------------------------------+----------+--------+----------+---------+----------+

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

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | ACTIVE | sharednet1=10.0.0.224 | CentOS8 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[2] Configure security settings for the security group you created above to access with SSH and ICMP.
# permit ICMP

[cent@dlp ~(keystone)]$
openstack security group rule create --protocol icmp --ingress secgroup01

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2020-11-17T02:20:33Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 73044cd6-e962-4556-ab47-f708aa8313c3 |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | 8cc9f93ed89f40e28a610d025462c020     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | dc94fe3a-6faa-4397-a8e9-703f86c687c9 |
| tags              | []                                   |
| updated_at        | 2020-11-17T02:20:33Z                 |
+-------------------+--------------------------------------+

# permit SSH

[cent@dlp ~(keystone)]$
openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2020-11-17T02:20:47Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 3f186089-e48d-4766-92d7-ebcc911ce9e1 |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | 8cc9f93ed89f40e28a610d025462c020     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | dc94fe3a-6faa-4397-a8e9-703f86c687c9 |
| tags              | []                                   |
| updated_at        | 2020-11-17T02:20:47Z                 |
+-------------------+--------------------------------------+

[cent@dlp ~(keystone)]$
openstack security group rule list

+--------------------------------------+-------------+-----------+-----------+------------+-----------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Remote Se |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+
| 13146d8f-5f99-4d93-b94a-ef11668338f5 | None        | IPv6      | ::/0      |            | 31077a... |
| 3b2da321-a840-4e4f-ac48-71bdd1995204 | None        | IPv4      | 0.0.0.0/0 |            | 31077a... |
| 3f186089-e48d-4766-92d7-ebcc911ce9e1 | tcp         | IPv4      | 0.0.0.0/0 | 22:22      | None      |
| 48d4d9fe-5c87-46c7-a1d7-40dda384e92b | None        | IPv4      | 0.0.0.0/0 |            | None      |
| 6c3896a9-c68f-40d1-bf1c-eddd32f1c7f5 | None        | IPv4      | 0.0.0.0/0 |            | None      |
| 73044cd6-e962-4556-ab47-f708aa8313c3 | icmp        | IPv4      | 0.0.0.0/0 |            | None      |
| afdbc33a-8fae-4dc3-802a-34d4befc08b5 | None        | IPv6      | ::/0      |            | None      |
| c2b3ad40-a9c3-4d5e-b56d-b0b69f5c3cbf | None        | IPv6      | ::/0      |            | None      |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+
[3] Login to the instance with SSH.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | ACTIVE | sharednet1=10.0.0.224 | CentOS8 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[cent@dlp ~(keystone)]$
ping 10.0.0.224 -c3

PING 10.0.0.224 (10.0.0.224) 56(84) bytes of data.
64 bytes from 10.0.0.224: icmp_seq=1 ttl=64 time=2.49 ms
64 bytes from 10.0.0.224: icmp_seq=2 ttl=64 time=0.891 ms
64 bytes from 10.0.0.224: icmp_seq=3 ttl=64 time=0.658 ms

--- 10.0.0.224 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 5ms
rtt min/avg/max/mdev = 0.658/1.347/2.492/0.815 ms

[cent@dlp ~(keystone)]$
ssh centos@10.0.0.224
The authenticity of host '10.0.0.224 (10.0.0.224)' can't be established.
ECDSA key fingerprint is SHA256:z6uZPMXfKk3znromBqn62hwkWSq8KvI/k0KQqVS7/QU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.224' (ECDSA) to the list of known hosts.
[centos@centos-8 ~]$     # logined
[4] If you'd like to stop an instance, it's possible to control with openstack command like follows.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | ACTIVE | sharednet1=10.0.0.224 | CentOS8 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

# stop instance

[cent@dlp ~(keystone)]$
openstack server stop CentOS-8

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+---------+-----------------------+---------+----------+
| ID                                   | Name     | Status  | Networks              | Image   | Flavor   |
+--------------------------------------+----------+---------+-----------------------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | SHUTOFF | sharednet1=10.0.0.224 | CentOS8 | m1.small |
+--------------------------------------+----------+---------+-----------------------+---------+----------+

# start instance

[cent@dlp ~(keystone)]$
openstack server start CentOS-8

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | ACTIVE | sharednet1=10.0.0.224 | CentOS8 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[5] It's possible to access with Web browser to get VNC console.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 24ca61e0-1463-4456-93ca-31c5cc6ba2b5 | CentOS-8 | ACTIVE | sharednet1=10.0.0.224 | CentOS8 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[cent@dlp ~(keystone)]$
openstack console url show CentOS-8

+-------+------------------------------------------------------------------------------------------+
| Field | Value                                                                                    |
+-------+------------------------------------------------------------------------------------------+
| type  | novnc                                                                                    |
| url   | http://10.0.0.30:6080/vnc_auto.html?path=%3Ftoken%3Dfb981be4-8d4e-46d6-aeb5-450af376acf0 |
+-------+------------------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content