CentOS Stream 9
Sponsored Link

OpenStack Bobcat : Create Instances2023/10/24

 
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.small  | 2048 |   10 |         0 |     1 | True      |
| 2  | m1.medium | 4096 |   10 |         0 |     2 | True      |
| 3  | m1.large  | 8192 |   10 |         0 |     4 | True      |
| 4  | m2.large  | 8192 |   10 |        10 |     4 | True      |
| 5  | m3.large  | 8192 |   50 |         0 |     4 | True      |
+----+-----------+------+------+-----------+-------+-----------+

# show available image list

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

+--------------------------------------+----------------+--------+
| ID                                   | Name           | Status |
+--------------------------------------+----------------+--------+
| bcbaa323-2438-4f5e-9473-49f633bb8f9b | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+

# show available network list

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| ec214091-7285-400b-8efe-5c4e566c51d7 | sharednet1 | 9544c8bf-c77b-4cee-a686-3a6cb1a39a8f |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

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

+-----------------+------------------------------------------------------------------------------+
| Field           | Value                                                                        |
+-----------------+------------------------------------------------------------------------------+
| created_at      | 2023-10-24T03:25:27Z                                                         |
| description     | secgroup01                                                                   |
| id              | d295a858-1d51-4e15-a1e9-eb13adcf7861                                         |
| name            | secgroup01                                                                   |
| project_id      | f4598dfd3b8a47149234b6892d18d5a4                                             |
| revision_number | 1                                                                            |
| rules           | created_at='2023-10-24T03:25:27Z', direction='egress', ethertype='IPv4', ... |
|                 | created_at='2023-10-24T03:25:27Z', direction='egress', ethertype='IPv6', ... |
| shared          | False                                                                        |
| stateful        | True                                                                         |
| tags            | []                                                                           |
| updated_at      | 2023-10-24T03:25:27Z                                                         |
+-----------------+------------------------------------------------------------------------------+

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

+--------------------------------------+------------+------------------------+----------------------------------+------+
| ID                                   | Name       | Description            | Project                          | Tags |
+--------------------------------------+------------+------------------------+----------------------------------+------+
| 163790db-7ca5-42e1-a6e7-70679409e2b3 | default    | Default security group | f4598dfd3b8a47149234b6892d18d5a4 | []   |
| d295a858-1d51-4e15-a1e9-eb13adcf7861 | secgroup01 | secgroup01             | f4598dfd3b8a47149234b6892d18d5a4 | []   |
+--------------------------------------+------------+------------------------+----------------------------------+------+

# 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 | 03:eb:ac:ca:38:90:ed:e6:35:8b:3f:45:e9:d5:62:ea |
| id          | mykey                                           |
| is_deleted  | None                                            |
| name        | mykey                                           |
| type        | ssh                                             |
| user_id     | d70a5f7908de4cd9aa8e189b725244a9                |
+-------------+-------------------------------------------------+

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

+-------+-------------------------------------------------+------+
| Name  | Fingerprint                                     | Type |
+-------+-------------------------------------------------+------+
| mykey | 03:eb:ac:ca:38:90:ed:e6:35:8b:3f:45:e9:d5:62:ea | 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.medium --image CentOS-Stream9 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS-St9
+-----------------------------+-------------------------------------------------------+
| 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                   | zyKdQtZAos2R                                          |
| config_drive                |                                                       |
| created                     | 2023-10-24T03:28:01Z                                  |
| flavor                      | m1.medium (2)                                         |
| hostId                      |                                                       |
| id                          | 37f143ed-bd44-48eb-97cd-2062951f0806                  |
| image                       | CentOS-Stream9 (bcbaa323-2438-4f5e-9473-49f633bb8f9b) |
| key_name                    | mykey                                                 |
| name                        | CentOS-St9                                            |
| progress                    | 0                                                     |
| project_id                  | f4598dfd3b8a47149234b6892d18d5a4                      |
| properties                  |                                                       |
| security_groups             | name='d295a858-1d51-4e15-a1e9-eb13adcf7861'           |
| status                      | BUILD                                                 |
| updated                     | 2023-10-24T03:28:01Z                                  |
| user_id                     | d70a5f7908de4cd9aa8e189b725244a9                      |
| volumes_attached            |                                                       |
+-----------------------------+-------------------------------------------------------+

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

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

+--------------------------------------+------------+--------+----------+----------------+-----------+
| ID                                   | Name       | Status | Networks | Image          | Flavor    |
+--------------------------------------+------------+--------+----------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | BUILD  |          | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+--------+----------+----------------+-----------+

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

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

+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| ID                                   | Name       | Status | Networks              | Image          | Flavor    |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | ACTIVE | sharednet1=10.0.0.210 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
[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              | 2023-10-24T03:29:10Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | b6b85f1a-cf41-45dc-a239-de96fca08240 |
| name                    | None                                 |
| normalized_cidr         | 0.0.0.0/0                            |
| port_range_max          | None                                 |
| port_range_min          | None                                 |
| project_id              | f4598dfd3b8a47149234b6892d18d5a4     |
| 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       | d295a858-1d51-4e15-a1e9-eb13adcf7861 |
| tags                    | []                                   |
| updated_at              | 2023-10-24T03:29:10Z                 |
+-------------------------+--------------------------------------+

# permit SSH

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

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| created_at              | 2023-10-24T03:29:29Z                 |
| description             |                                      |
| direction               | ingress                              |
| ether_type              | IPv4                                 |
| id                      | 698a028e-5c35-44ad-aa61-88155a89d378 |
| name                    | None                                 |
| normalized_cidr         | 0.0.0.0/0                            |
| port_range_max          | 22                                   |
| port_range_min          | 22                                   |
| project_id              | f4598dfd3b8a47149234b6892d18d5a4     |
| 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       | d295a858-1d51-4e15-a1e9-eb13adcf7861 |
| tags                    | []                                   |
| updated_at              | 2023-10-24T03:29:29Z                 |
+-------------------------+--------------------------------------+

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

+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Direction | Remote Security Group | Remote Address Group |
+--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+
| 1e253bec-8405-4bc7-9c2f-463fd1421065 | None        | IPv4      | 0.0.0.0/0 |            | egress    | None                  | None                 |
| 698a028e-5c35-44ad-aa61-88155a89d378 | tcp         | IPv4      | 0.0.0.0/0 | 22:22      | ingress   | None                  | None                 |
| b6b85f1a-cf41-45dc-a239-de96fca08240 | icmp        | IPv4      | 0.0.0.0/0 |            | ingress   | None                  | None                 |
| bfaf112d-e4a6-4e4f-adc1-2365f0680713 | 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    |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | ACTIVE | sharednet1=10.0.0.210 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+

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

PING 10.0.0.210 (10.0.0.210) 56(84) bytes of data.
64 bytes from 10.0.0.210: icmp_seq=1 ttl=64 time=1.02 ms
64 bytes from 10.0.0.210: icmp_seq=2 ttl=64 time=0.605 ms
64 bytes from 10.0.0.210: icmp_seq=3 ttl=64 time=0.456 ms

--- 10.0.0.210 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 0.456/0.694/1.021/0.239 ms

[cent@dlp ~(keystone)]$
ssh centos@10.0.0.222
The authenticity of host '10.0.0.210 (10.0.0.210)' can't be established.
ED25519 key fingerprint is SHA256:X8VMxmPAD+pHBLZ4ZWoEe6opKQBR1PUPKxREIf3Z1to.
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.210' (ED25519) to the list of known hosts.
[centos@centos-st9 ~]$     # 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    |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | ACTIVE | sharednet1=10.0.0.210 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+

# stop instance

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

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

+--------------------------------------+------------+---------+-----------------------+----------------+-----------+
| ID                                   | Name       | Status  | Networks              | Image          | Flavor    |
+--------------------------------------+------------+---------+-----------------------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | SHUTOFF | sharednet1=10.0.0.210 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+---------+-----------------------+----------------+-----------+

# start instance

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

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

+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| ID                                   | Name       | Status | Networks              | Image          | Flavor    |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | ACTIVE | sharednet1=10.0.0.210 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
[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    |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+
| 37f143ed-bd44-48eb-97cd-2062951f0806 | CentOS-St9 | ACTIVE | sharednet1=10.0.0.210 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+--------+-----------------------+----------------+-----------+

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

+----------+-----------------------------------------------------------------------------------------------+
| Field    | Value                                                                                         |
+----------+-----------------------------------------------------------------------------------------------+
| protocol | vnc                                                                                           |
| type     | novnc                                                                                         |
| url      | https://dlp.srv.world:6080/vnc_auto.html?path=%3Ftoken%3D328d84ce-6028-439b-aa97-2feacd0131d5 |
+----------+-----------------------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content