Ubuntu 20.04
Sponsored Link

OpenStack Wallaby : Create Instances2021/04/18

 
Create and Start Virtual Machine Instances.
[1] Login as a common 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.
ubuntu@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)\$ '
ubuntu@dlp:~$
chmod 600 ~/keystonerc

ubuntu@dlp:~$
source ~/keystonerc

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

ubuntu@dlp ~(keystone)$
openstack flavor list

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

# confirm available image list

ubuntu@dlp ~(keystone)$
openstack image list

+--------------------------------------+------------+--------+
| ID                                   | Name       | Status |
+--------------------------------------+------------+--------+
| 8df08a02-7c19-465e-8862-53eb2319918d | Ubuntu2004 | active |
+--------------------------------------+------------+--------+

# confirm available network list

ubuntu@dlp ~(keystone)$
openstack network list

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| e44d8bc4-2268-413e-aaa8-7aa96e623ac4 | sharednet1 | 448c0da9-6dbb-4c79-9042-e2fc1af8fab2 |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

ubuntu@dlp ~(keystone)$
openstack security group create secgroup01

+-----------------+---------------------------------------------------------------------------+
| Field           | Value                                                                     |
+-----------------+---------------------------------------------------------------------------+
| created_at      | 2021-04-15T06:04:45Z                                                      |
| description     | secgroup01                                                                |
| id              | 6f43bcd6-49de-4a89-bcd0-af3ed797db5f                                      |
| name            | secgroup01                                                                |
| project_id      | e256a7323fda468fb02e8f1975fce488                                          |
| revision_number | 1                                                                         |
| rules           | created_at='2021-04-15T06:04:45Z', direction='egress', ethertype='IPv6... |
|                 | created_at='2021-04-15T06:04:45Z', direction='egress', ethertype='IPv4... |
| stateful        | True                                                                      |
| tags            | []                                                                        |
| updated_at      | 2021-04-15T06:04:45Z                                                      |
+-----------------+---------------------------------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack security group list

+--------------------------------------+------------+------------------------+----------------------------------+------+
| ID                                   | Name       | Description            | Project                          | Tags |
+--------------------------------------+------------+------------------------+----------------------------------+------+
| 6f43bcd6-49de-4a89-bcd0-af3ed797db5f | secgroup01 | secgroup01             | e256a7323fda468fb02e8f1975fce488 | []   |
| c2d5b6c7-515e-4d01-8c65-d59fe7ffe09f | default    | Default security group | e256a7323fda468fb02e8f1975fce488 | []   |
+--------------------------------------+------------+------------------------+----------------------------------+------+

# create a SSH keypair for connecting to instances

ubuntu@dlp ~(keystone)$
ssh-keygen -q -N ""

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

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

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| created_at  | None                                            |
| fingerprint | 7b:0d:88:1f:85:d3:49:46:63:dc:0c:3d:11:52:50:60 |
| id          | mykey                                           |
| is_deleted  | None                                            |
| name        | mykey                                           |
| type        | ssh                                             |
| user_id     | 3ebb8ec1b4fc467da96379caef902df7                |
+-------------+-------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack keypair list

+-------+-------------------------------------------------+------+
| Name  | Fingerprint                                     | Type |
+-------+-------------------------------------------------+------+
| mykey | 7b:0d:88:1f:85:d3:49:46:63:dc:0c:3d:11:52:50:60 | ssh  |
+-------+-------------------------------------------------+------+

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

# create and boot an instance

ubuntu@dlp ~(keystone)$
openstack server create --flavor m1.small --image Ubuntu2004 --security-group secgroup01 --nic net-id=$netID --key-name mykey Ubuntu-2004
+-----------------------------+---------------------------------------------------+
| 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                   | Y4gxVF6TPZau                                      |
| config_drive                |                                                   |
| created                     | 2021-04-15T06:07:06Z                              |
| flavor                      | m1.small (0)                                      |
| hostId                      |                                                   |
| id                          | cc9d7eb5-2a78-40af-9268-cf45c4a109a4              |
| image                       | Ubuntu2004 (8df08a02-7c19-465e-8862-53eb2319918d) |
| key_name                    | mykey                                             |
| name                        | Ubuntu-2004                                       |
| progress                    | 0                                                 |
| project_id                  | e256a7323fda468fb02e8f1975fce488                  |
| properties                  |                                                   |
| security_groups             | name='6f43bcd6-49de-4a89-bcd0-af3ed797db5f'       |
| status                      | BUILD                                             |
| updated                     | 2021-04-15T06:07:06Z                              |
| user_id                     | 3ebb8ec1b4fc467da96379caef902df7                  |
| volumes_attached            |                                                   |
+-----------------------------+---------------------------------------------------+

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

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+----------+------------+----------+
| ID                                   | Name        | Status | Networks | Image      | Flavor   |
+--------------------------------------+-------------+--------+----------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | BUILD  |          | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+--------+----------+------------+----------+

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

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | ACTIVE | sharednet1=10.0.0.241 | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
[2] Configure security settings for the security group you created above to access with SSH and ICMP.
# permit ICMP

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

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| created_at              | 2021-04-15T06:08:01Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | 470843e6-f1a0-455a-b4c7-6edb65bdef82 |
| name                    | None                                 |
| port_range_max          | None                                 |
| port_range_min          | None                                 |
| project_id              | e256a7323fda468fb02e8f1975fce488     |
| protocol                | icmp                                 |
| remote_address_group_id | None                                 |
| remote_group_id         | None                                 |
| remote_ip_prefix        | 0.0.0.0/0                            |
| revision_number         | 0                                    |
| security_group_id       | 6f43bcd6-49de-4a89-bcd0-af3ed797db5f |
| tags                    | []                                   |
| updated_at              | 2021-04-15T06:08:01Z                 |
+-------------------------+--------------------------------------+

# permit SSH

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

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| created_at              | 2021-04-15T06:08:15Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | cafa8b64-4887-4aae-a6cf-50a1383041cb |
| name                    | None                                 |
| port_range_max          | 22                                   |
| port_range_min          | 22                                   |
| project_id              | e256a7323fda468fb02e8f1975fce488     |
| protocol                | tcp                                  |
| remote_address_group_id | None                                 |
| remote_group_id         | None                                 |
| remote_ip_prefix        | 0.0.0.0/0                            |
| revision_number         | 0                                    |
| security_group_id       | 6f43bcd6-49de-4a89-bcd0-af3ed797db5f |
| tags                    | []                                   |
| updated_at              | 2021-04-15T06:08:15Z                 |
+-------------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack security group rule list secgroup01

+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Direction | Remote Security Group | Remote Address Group |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
| 470843e6-f1a0-455a-b4c7-6edb65bdef82 | icmp        | IPv4      | 0.0.0.0/0 |            | ingress   | None                  | None                 |
| 5f4effd6-4c7b-439e-9301-f769adc04b1b | None        | IPv6      | ::/0      |            | egress    | None                  | None                 |
| 99ffac58-6a15-4ec0-9e86-c85341f7c221 | None        | IPv4      | 0.0.0.0/0 |            | egress    | None                  | None                 |
| cafa8b64-4887-4aae-a6cf-50a1383041cb | tcp         | IPv4      | 0.0.0.0/0 | 22:22      | ingress   | None                  | None                 |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
[3] Login to the instance with SSH.
ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | ACTIVE | sharednet1=10.0.0.241 | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

ubuntu@dlp ~(keystone)$
ping 10.0.0.241 -c3

PING 10.0.0.241 (10.0.0.241) 56(84) bytes of data.
64 bytes from 10.0.0.241: icmp_seq=1 ttl=64 time=1.13 ms
64 bytes from 10.0.0.241: icmp_seq=2 ttl=64 time=0.585 ms
64 bytes from 10.0.0.241: icmp_seq=3 ttl=64 time=0.507 ms

--- 10.0.0.241 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.507/0.741/1.131/0.277 ms

ubuntu@dlp ~(keystone)$
ssh ubuntu@10.0.0.241
The authenticity of host '10.0.0.241 (10.0.0.241)' can't be established.
ECDSA key fingerprint is SHA256:xkwzwxgsQmq9nBZ7/uN2+VDWiCL+00WUwjiUDwh7FsQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.241' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-71-generic x86_64)

.....
.....

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu-2004:~$     # logined
[4] If you'd like to stop an instance, it's possible to control with openstack command like follows.
ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | ACTIVE | sharednet1=10.0.0.241 | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

# stop instance

ubuntu@dlp ~(keystone)$
openstack server stop Ubuntu-2004

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+---------+-----------------------+------------+----------+
| ID                                   | Name        | Status  | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+---------+-----------------------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | SHUTOFF | sharednet1=10.0.0.241 | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+---------+-----------------------+------------+----------+

# start instance

ubuntu@dlp ~(keystone)$
openstack server start Ubuntu-2004

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | ACTIVE | sharednet1=10.0.0.241 | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
[5] It's possible to access with Web browser to get VNC console.
ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| cc9d7eb5-2a78-40af-9268-cf45c4a109a4 | Ubuntu-2004 | ACTIVE | sharednet1=10.0.0.241 | Ubuntu2004 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

ubuntu@dlp ~(keystone)$
openstack console url show Ubuntu-2004

+----------+------------------------------------------------------------------------------------------+
| Field    | Value                                                                                    |
+----------+------------------------------------------------------------------------------------------+
| protocol | vnc                                                                                      |
| type     | novnc                                                                                    |
| url      | http://10.0.0.30:6080/vnc_auto.html?path=%3Ftoken%3D0cab71a5-4012-43ed-a9eb-715b7c260cfc |
+----------+------------------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content