OpenStack Antelope : Create Instances2023/04/14 |
Create and Start Virtual Machine Instance.
|
|
[1] | Login with a user and create a config for authentication of Keystone. 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=https://dlp.srv.world:5000 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 | +----+-----------+------+------+-----------+-------+-----------+ | 1 | m1.small | 2048 | 10 | 0 | 1 | True | | 2 | m1.medium | 4096 | 10 | 0 | 2 | True | | 3 | m1.large | 8192 | 20 | 0 | 4 | True | +----+-----------+------+------+-----------+-------+-----------+ # show available image list [cent@dlp ~(keystone)]$ openstack image list +--------------------------------------+----------------+--------+ | ID | Name | Status | +--------------------------------------+----------------+--------+ | 6afab1f1-c2e0-42c5-9c86-659f56174b9d | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+ # show available network list [cent@dlp ~(keystone)]$ openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | b176d051-6a33-4b77-9cfd-13d86b51f657 | sharednet1 | 0a491127-28f7-4c9c-b7d3-8b8f449912a0 | +--------------------------------------+------------+--------------------------------------+ # create a security group for instances [cent@dlp ~(keystone)]$ openstack security group create secgroup01 +-----------------+--------------------------------------------------------------------------------+ | Field | Value | +-----------------+--------------------------------------------------------------------------------+ | created_at | 2023-04-14T02:22:35Z | | description | secgroup01 | | id | c761c71b-265d-4802-9c7d-0b85e0680e06 | | name | secgroup01 | | project_id | 17b52bb0db9440549d400290cec02c1d | | revision_number | 1 | | rules | created_at='2023-04-14T02:22:35Z', direction='egress', ethertype='IPv6', ..... | | | created_at='2023-04-14T02:22:35Z', direction='egress', ethertype='IPv4', ..... | | shared | False | | stateful | True | | tags | [] | | updated_at | 2023-04-14T02:22:35Z | +-----------------+--------------------------------------------------------------------------------+[cent@dlp ~(keystone)]$ openstack security group list +--------------------------------------+------------+------------------------+----------------------------------+------+ | ID | Name | Description | Project | Tags | +--------------------------------------+------------+------------------------+----------------------------------+------+ | 340b7b87-9f3f-430c-8f22-267d1c663865 | default | Default security group | 17b52bb0db9440549d400290cec02c1d | [] | | c761c71b-265d-4802-9c7d-0b85e0680e06 | secgroup01 | secgroup01 | 17b52bb0db9440549d400290cec02c1d | [] | +--------------------------------------+------------+------------------------+----------------------------------+------+ # 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 | 4c:9c:17:be:f5:e0:ea:db:fc:ec:29:e3:ca:20:1e:cb | | id | mykey | | is_deleted | None | | name | mykey | | type | ssh | | user_id | 1ed6032943cb4e5d907371a20adae1c0 | +-------------+-------------------------------------------------+[cent@dlp ~(keystone)]$ openstack keypair list +-------+-------------------------------------------------+------+ | Name | Fingerprint | Type | +-------+-------------------------------------------------+------+ | mykey | 4c:9c:17:be:f5:e0:ea:db:fc:ec:29:e3:ca:20:1e:cb | 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 | FyRmxN5UnZxi | | config_drive | | | created | 2023-04-14T02:25:52Z | | flavor | m1.medium (2) | | hostId | | | id | fbb05592-02fd-42a7-bc73-d9f526431d4e | | image | CentOS-Stream9 (6afab1f1-c2e0-42c5-9c86-659f56174b9d) | | key_name | mykey | | name | CentOS-St9 | | progress | 0 | | project_id | 17b52bb0db9440549d400290cec02c1d | | properties | | | security_groups | name='c761c71b-265d-4802-9c7d-0b85e0680e06' | | status | BUILD | | updated | 2023-04-14T02:25:52Z | | user_id | 1ed6032943cb4e5d907371a20adae1c0 | | volumes_attached | | +-----------------------------+-------------------------------------------------------+ # show status ([BUILD] status is shown when building instance) [cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+------------+--------+----------+----------------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+------------+--------+----------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | 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 | +--------------------------------------+------------+--------+-----------------------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | CentOS-St9 | ACTIVE | sharednet1=10.0.0.222 | 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-04-14T02:27:38Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 788c37e3-3956-42b2-b21a-bf1c7a8e4a48 | | name | None | | normalized_cidr | 0.0.0.0/0 | | port_range_max | None | | port_range_min | None | | project_id | 17b52bb0db9440549d400290cec02c1d | | 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 | c761c71b-265d-4802-9c7d-0b85e0680e06 | | tags | [] | | updated_at | 2023-04-14T02:27:38Z | +-------------------------+--------------------------------------+ # permit SSH [cent@dlp ~(keystone)]$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2023-04-14T02:27:58Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | da45affc-603e-47b4-af3c-bbef588a3afa | | name | None | | normalized_cidr | 0.0.0.0/0 | | port_range_max | 22 | | port_range_min | 22 | | project_id | 17b52bb0db9440549d400290cec02c1d | | 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 | c761c71b-265d-4802-9c7d-0b85e0680e06 | | tags | [] | | updated_at | 2023-04-14T02:27:58Z | +-------------------------+--------------------------------------+[cent@dlp ~(keystone)]$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | 788c37e3-3956-42b2-b21a-bf1c7a8e4a48 | icmp | IPv4 | 0.0.0.0/0 | | ingress | None | None | | 86d4925a-5622-4bb9-9eb3-1ee49540e23b | None | IPv6 | ::/0 | | egress | None | None | | d06ad67e-ddfc-40bd-8335-ed7d6f1ca9f4 | None | IPv4 | 0.0.0.0/0 | | egress | None | None | | da45affc-603e-47b4-af3c-bbef588a3afa | tcp | IPv4 | 0.0.0.0/0 | 22:22 | ingress | None | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ |
[3] | Login to the instance with SSH. |
[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+------------+--------+-----------------------+----------------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+------------+--------+-----------------------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | CentOS-St9 | ACTIVE | sharednet1=10.0.0.222 | CentOS-Stream9 | m1.medium | +--------------------------------------+------------+--------+-----------------------+----------------+-----------+[cent@dlp ~(keystone)]$ ping 10.0.0.222 -c3 PING 10.0.0.222 (10.0.0.222) 56(84) bytes of data. 64 bytes from 10.0.0.222: icmp_seq=1 ttl=64 time=0.908 ms 64 bytes from 10.0.0.222: icmp_seq=2 ttl=64 time=0.412 ms 64 bytes from 10.0.0.222: icmp_seq=3 ttl=64 time=0.461 ms --- 10.0.0.222 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2045ms rtt min/avg/max/mdev = 0.412/0.593/0.908/0.223 ms[cent@dlp ~(keystone)]$ ssh centos@10.0.0.222
The authenticity of host '10.0.0.222 (10.0.0.222)' can't be established. ED25519 key fingerprint is SHA256:A+hDHolX0kV5K6pOAHLr/RBY1dBuOp/9x8tTn0KBAq4. 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.222' (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 | +--------------------------------------+------------+--------+-----------------------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | CentOS-St9 | ACTIVE | sharednet1=10.0.0.222 | 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 | +--------------------------------------+------------+---------+-----------------------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | CentOS-St9 | SHUTOFF | sharednet1=10.0.0.222 | 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 | +--------------------------------------+------------+--------+-----------------------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | CentOS-St9 | ACTIVE | sharednet1=10.0.0.222 | 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 | +--------------------------------------+------------+--------+-----------------------+----------------+-----------+ | fbb05592-02fd-42a7-bc73-d9f526431d4e | CentOS-St9 | ACTIVE | sharednet1=10.0.0.222 | 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%3D871ed8f1-57b1-4278-afb5-dc4f27cea325 | +----------+-----------------------------------------------------------------------------------------------+ |
[6] | Access to the URL which was displayed by the command above. |
Sponsored Link |
|