CentOS Stream 9
Sponsored Link

OpenStack Epoxy : Create Instances2025/05/21

 

Create and Start Virtual Machine Instance.

[1] Login as a user that you set environment variables for Openstack and then create and start virtual machine instance.
# show available [flavor] list

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

+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 1  | m1.tiny   |  2048 |   10 |         0 |     1 | True      |
| 2  | m1.small  |  4096 |   10 |         0 |     2 | True      |
| 3  | m1.medium |  8192 |   10 |         0 |     4 | True      |
| 4  | m1.large  | 16384 |   10 |         0 |     8 | True      |
| 5  | m2.large  | 16384 |   10 |        10 |     8 | True      |
+----+-----------+-------+------+-----------+-------+-----------+

# show available image list

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

+--------------------------------------+----------------+--------+
| ID                                   | Name           | Status |
+--------------------------------------+----------------+--------+
| 8bbf2495-d1b0-4c12-89d3-bf6ca71b2a2d | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+

# show available network list

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| 394f7977-0481-4572-b673-f2fc99b683d0 | sharednet1 | 61e6bddb-4856-455f-8760-225ae99a8e1f |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

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

+-----------------+----------------------------------------------------------------------------+
| Field           | Value                                                                      |
+-----------------+----------------------------------------------------------------------------+
| created_at      | 2025-05-21T01:32:53Z                                                       |
| description     | secgroup01                                                                 |
| id              | 8ce2f416-7b9b-4493-a275-1b4ed93c9da5                                       |
| name            | secgroup01                                                                 |
| project_id      | 6cd379304e2447da8514a66bb6cdfda5                                           |
| revision_number | 1                                                                          |
| rules           | created_at='2025-05-21T01:32:53Z', direction='egress', ethertype='IPv4'... |
|                 | created_at='2025-05-21T01:32:53Z', direction='egress', ethertype='IPv6'... |
| shared          | False                                                                      |
| stateful        | True                                                                       |
| tags            | []                                                                         |
| updated_at      | 2025-05-21T01:32:53Z                                                       |
+-----------------+----------------------------------------------------------------------------+

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

+--------------------------------------+------------+------------------------+----------------------------------+------+
| ID                                   | Name       | Description            | Project                          | Tags |
+--------------------------------------+------------+------------------------+----------------------------------+------+
| 82973c6c-1439-48eb-bf28-68dcea0b49de | default    | Default security group | 6cd379304e2447da8514a66bb6cdfda5 | []   |
| 8ce2f416-7b9b-4493-a275-1b4ed93c9da5 | secgroup01 | secgroup01             | 6cd379304e2447da8514a66bb6cdfda5 | []   |
+--------------------------------------+------------+------------------------+----------------------------------+------+

# create an 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                                           |
+-------------+-------------------------------------------------+
| created_at  | None                                            |
| fingerprint | dc:a7:f4:79:31:05:34:2c:4a:1b:b3:b2:0c:d5:9f:9e |
| id          | mykey                                           |
| is_deleted  | None                                            |
| name        | mykey                                           |
| type        | ssh                                             |
| user_id     | b6e98dc2822541dd8c4571ac4ed54778                |
+-------------+-------------------------------------------------+

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

+-------+-------------------------------------------------+------+
| Name  | Fingerprint                                     | Type |
+-------+-------------------------------------------------+------+
| mykey | dc:a7:f4:79:31:05:34:2c:4a:1b:b3:b2:0c:d5:9f:9e | ssh  |
+-------+-------------------------------------------------+------+

[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 CentOS-Stream9 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS-9
+-------------------------------------+---------------------------------------------------------+
| Field                               | Value                                                   |
+-------------------------------------+---------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                  |
| OS-EXT-AZ:availability_zone         | None                                                    |
| OS-EXT-SRV-ATTR:host                | None                                                    |
| OS-EXT-SRV-ATTR:hostname            | centos-9                                                |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                                    |
| OS-EXT-SRV-ATTR:instance_name       | None                                                    |
| OS-EXT-SRV-ATTR:kernel_id           | None                                                    |
| OS-EXT-SRV-ATTR:launch_index        | None                                                    |
| OS-EXT-SRV-ATTR:ramdisk_id          | None                                                    |
| OS-EXT-SRV-ATTR:reservation_id      | None                                                    |
| OS-EXT-SRV-ATTR:root_device_name    | None                                                    |
| OS-EXT-SRV-ATTR:user_data           | None                                                    |
| OS-EXT-STS:power_state              | N/A                                                     |
| 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                          | None                                                    |
| accessIPv6                          | None                                                    |
| addresses                           | N/A                                                     |
| adminPass                           | KB5yDYgFZjzW                                            |
| config_drive                        | None                                                    |
| created                             | 2025-05-21T01:38:03Z                                    |
| description                         | None                                                    |
| flavor                              | description=, disk='10', ephemeral='0', , id='m1.sma... |
| hostId                              | None                                                    |
| host_status                         | None                                                    |
| id                                  | cb0b29ae-0b4d-49a7-9178-caff132586ea                    |
| image                               | CentOS-Stream9 (8bbf2495-d1b0-4c12-89d3-bf6ca71b2a2d)   |
| key_name                            | mykey                                                   |
| locked                              | None                                                    |
| locked_reason                       | None                                                    |
| name                                | CentOS-9                                                |
| pinned_availability_zone            | None                                                    |
| progress                            | None                                                    |
| project_id                          | 6cd379304e2447da8514a66bb6cdfda5                        |
| properties                          | None                                                    |
| security_groups                     | name='8ce2f416-7b9b-4493-a275-1b4ed93c9da5'             |
| server_groups                       | None                                                    |
| status                              | BUILD                                                   |
| tags                                |                                                         |
| trusted_image_certificates          | None                                                    |
| updated                             | 2025-05-21T01:38:03Z                                    |
| user_id                             | b6e98dc2822541dd8c4571ac4ed54778                        |
| volumes_attached                    |                                                         |
+-------------------------------------+---------------------------------------------------------+

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

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

+--------------------------------------+----------+--------+----------+----------------+----------+
| ID                                   | Name     | Status | Networks | Image          | Flavor   |
+--------------------------------------+----------+--------+----------+----------------+----------+
| cb0b29ae-0b4d-49a7-9178-caff132586ea | CentOS-9 | BUILD  |          | CentOS-Stream9 | m1.small |
+--------------------------------------+----------+--------+----------+----------------+----------+

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

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

+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| ID                                   | Name     | Status | Networks              | Image          | Flavor   |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| cb0b29ae-0b4d-49a7-9178-caff132586ea | CentOS-9 | ACTIVE | sharednet1=10.0.0.232 | CentOS-Stream9 | 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                                |
+-------------------------+--------------------------------------+
| belongs_to_default_sg   | False                                |
| created_at              | 2025-05-21T01:39:55Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | 7d9eb522-4c8a-4f6e-9304-06109d24eb72 |
| name                    | None                                 |
| normalized_cidr         | 0.0.0.0/0                            |
| port_range_max          | None                                 |
| port_range_min          | None                                 |
| project_id              | 6cd379304e2447da8514a66bb6cdfda5     |
| 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       | 8ce2f416-7b9b-4493-a275-1b4ed93c9da5 |
| tags                    | []                                   |
| updated_at              | 2025-05-21T01:39:55Z                 |
+-------------------------+--------------------------------------+

# permit SSH

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

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| belongs_to_default_sg   | False                                |
| created_at              | 2025-05-21T01:40:12Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | c77f020e-0fd7-4551-a2b3-4f69353c04ac |
| name                    | None                                 |
| normalized_cidr         | 0.0.0.0/0                            |
| port_range_max          | 22                                   |
| port_range_min          | 22                                   |
| project_id              | 6cd379304e2447da8514a66bb6cdfda5     |
| 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       | 8ce2f416-7b9b-4493-a275-1b4ed93c9da5 |
| tags                    | []                                   |
| updated_at              | 2025-05-21T01:40:12Z                 |
+-------------------------+--------------------------------------+

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

+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Direction | Remote Security Group | Remote Address Group |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
| 02858970-79fd-4d08-bdb4-efc5469edc84 | None        | IPv4      | 0.0.0.0/0 |            | egress    | None                  | None                 |
| 7d9eb522-4c8a-4f6e-9304-06109d24eb72 | icmp        | IPv4      | 0.0.0.0/0 |            | ingress   | None                  | None                 |
| c77f020e-0fd7-4551-a2b3-4f69353c04ac | tcp         | IPv4      | 0.0.0.0/0 | 22:22      | ingress   | None                  | None                 |
| cfb3e7e4-c1a4-485b-ad63-b487c1303e3c | None        | IPv6      | ::/0      |            | egress    | None                  | None                 |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
[3] Login to the instance with SSH.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| ID                                   | Name     | Status | Networks              | Image          | Flavor   |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| cb0b29ae-0b4d-49a7-9178-caff132586ea | CentOS-9 | ACTIVE | sharednet1=10.0.0.232 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+

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

PING 10.0.0.232 (10.0.0.232) 56(84) bytes of data.
64 bytes from 10.0.0.232: icmp_seq=1 ttl=64 time=0.912 ms
64 bytes from 10.0.0.232: icmp_seq=2 ttl=64 time=0.579 ms
64 bytes from 10.0.0.232: icmp_seq=3 ttl=64 time=0.292 ms

--- 10.0.0.232 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2011ms
rtt min/avg/max/mdev = 0.292/0.594/0.912/0.253 ms

[cent@dlp ~(keystone)]$
ssh centos@10.0.0.230
The authenticity of host '10.0.0.232 (10.0.0.232)' can't be established.
ED25519 key fingerprint is SHA256:+W+LkUCU4IwFd5vn0hfoh5tceVc5fQ2kodylrGfW/M4.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.232' (ED25519) to the list of known hosts.
[centos@centos-9 ~]$     # 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   |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| cb0b29ae-0b4d-49a7-9178-caff132586ea | CentOS-9 | ACTIVE | sharednet1=10.0.0.232 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+

# stop instance

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

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

+--------------------------------------+----------+---------+-----------------------+----------------+----------+
| ID                                   | Name     | Status  | Networks              | Image          | Flavor   |
+--------------------------------------+----------+---------+-----------------------+----------------+----------+
| cb0b29ae-0b4d-49a7-9178-caff132586ea | CentOS-9 | SHUTOFF | sharednet1=10.0.0.232 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------+---------+-----------------------+----------------+----------+

# start instance

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

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

+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| ID                                   | Name     | Status | Networks              | Image          | Flavor   |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+
| cb0b29ae-0b4d-49a7-9178-caff132586ea | CentOS-9 | ACTIVE | sharednet1=10.0.0.232 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------+--------+-----------------------+----------------+----------+
[5] It's possible to access with Web browser to get VNC console.
[cent@dlp ~(keystone)]$
openstack console url show CentOS-9

+----------+-----------------------------------------------------------------------------------------------+
| Field    | Value                                                                                         |
+----------+-----------------------------------------------------------------------------------------------+
| protocol | vnc                                                                                           |
| type     | novnc                                                                                         |
| url      | https://dlp.srv.world:6080/vnc_auto.html?path=%3Ftoken%3D1db51126-5462-4cf7-bad4-6d1d742344db |
+----------+-----------------------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content