OpenStack Zed : Create Instances2023/06/27 |
Create and Start Virtual Machine Instances.
|
|
[1] | Login as a common 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. |
debian@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/v3 export OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2 export PS1='\u@\h \W(keystone)\$ '
debian@dlp:~$
chmod 600 ~/keystonerc debian@dlp:~$ source ~/keystonerc debian@dlp ~(keystone)$ echo "source ~/keystonerc " >> ~/.bash_profile
# confirm available [flavor] list debian@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 | m2.large | 8192 | 10 | 10 | 4 | True | +----+-----------+------+------+-----------+-------+-----------+ # confirm available image list debian@dlp ~(keystone)$ openstack image list +--------------------------------------+----------+--------+ | ID | Name | Status | +--------------------------------------+----------+--------+ | 9e7f953f-9918-453d-aeeb-def892492966 | Debian12 | active | +--------------------------------------+----------+--------+ # confirm available network list debian@dlp ~(keystone)$ openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | 69962e3a-3e00-41b8-866b-d67cc50b11b9 | sharednet1 | 2af9e60c-505e-439d-80af-61636d4266ca | +--------------------------------------+------------+--------------------------------------+ # create a security group for instances debian@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+-----------------------------------------------------------------------------+ | Field | Value | +-----------------+-----------------------------------------------------------------------------+ | created_at | 2023-06-27T02:43:45Z | | description | secgroup01 | | id | dfc47032-e1bd-4283-b156-faf9d19591d2 | | name | secgroup01 | | project_id | 1c2f5dc8c4f9494fbaaa4217c8e3585a | | revision_number | 1 | | rules | created_at='2023-06-27T02:43:45Z', direction='egress', ethertype='IPv4',... | | | created_at='2023-06-27T02:43:45Z', direction='egress', ethertype='IPv6',... | | stateful | True | | tags | [] | | updated_at | 2023-06-27T02:43:45Z | +-----------------+-----------------------------------------------------------------------------+debian@dlp ~(keystone)$ openstack security group list +--------------------------------------+------------+------------------------+----------------------------------+------+ | ID | Name | Description | Project | Tags | +--------------------------------------+------------+------------------------+----------------------------------+------+ | 75505dff-0fa3-4737-be7e-5ebee1984d5f | default | Default security group | 1c2f5dc8c4f9494fbaaa4217c8e3585a | [] | | dfc47032-e1bd-4283-b156-faf9d19591d2 | secgroup01 | secgroup01 | 1c2f5dc8c4f9494fbaaa4217c8e3585a | [] | +--------------------------------------+------------+------------------------+----------------------------------+------+ # create an SSH keypair for connecting to instances debian@dlp ~(keystone)$ ssh-keygen -q -N "" Enter file in which to save the key (/home/debian/.ssh/id_rsa): # add public-key debian@dlp ~(keystone)$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | created_at | None | | fingerprint | 0a:f8:20:15:58:6c:03:4b:6e:69:f0:9e:36:2a:9d:36 | | id | mykey | | is_deleted | None | | name | mykey | | type | ssh | | user_id | de51d5f0ee2c485885877d21f5b424e0 | +-------------+-------------------------------------------------+debian@dlp ~(keystone)$ openstack keypair list +-------+-------------------------------------------------+------+ | Name | Fingerprint | Type | +-------+-------------------------------------------------+------+ | mykey | 0a:f8:20:15:58:6c:03:4b:6e:69:f0:9e:36:2a:9d:36 | ssh | +-------+-------------------------------------------------+------+
debian@dlp ~(keystone)$
netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }') # create and boot an instance debian@dlp ~(keystone)$ openstack server create --flavor m1.medium --image Debian12 --security-group secgroup01 --nic net-id=$netID --key-name mykey Debian-12
+-----------------------------+-------------------------------------------------+ | 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 | 46jELXmPLZ3F | | config_drive | | | created | 2023-06-27T06:13:57Z | | flavor | m1.medium (2) | | hostId | | | id | 66f3eed0-9b19-4260-88ce-fb640ca55256 | | image | Debian12 (9e7f953f-9918-453d-aeeb-def892492966) | | key_name | mykey | | name | Debian-12 | | progress | 0 | | project_id | 1c2f5dc8c4f9494fbaaa4217c8e3585a | | properties | | | security_groups | name='dfc47032-e1bd-4283-b156-faf9d19591d2' | | status | BUILD | | updated | 2023-06-27T06:13:57Z | | user_id | de51d5f0ee2c485885877d21f5b424e0 | | volumes_attached | | +-----------------------------+-------------------------------------------------+ # show status ([BUILD] status is shown when building instance) debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+----------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+----------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | BUILD | | Debian12 | m1.medium | +--------------------------------------+-----------+--------+----------+----------+-----------+ # when starting normally, the status turns to [ACTIVE] debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | ACTIVE | sharednet1=10.0.0.252 | Debian12 | m1.medium | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ |
[2] | Configure security settings for the security group you created above to access with SSH and ICMP. |
# permit ICMP debian@dlp ~(keystone)$ openstack security group rule create --protocol icmp --ingress secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2023-06-27T02:49:49Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 71d9a4fb-43f3-49c3-824c-640bd104f8b9 | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 1c2f5dc8c4f9494fbaaa4217c8e3585a | | 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 | dfc47032-e1bd-4283-b156-faf9d19591d2 | | tags | [] | | updated_at | 2023-06-27T02:49:49Z | +-------------------------+--------------------------------------+ # permit SSH debian@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2023-06-27T02:50:09Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 35284802-7475-4a38-bf2f-ff75c16b5f60 | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 1c2f5dc8c4f9494fbaaa4217c8e3585a | | 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 | dfc47032-e1bd-4283-b156-faf9d19591d2 | | tags | [] | | updated_at | 2023-06-27T02:50:09Z | +-------------------------+--------------------------------------+debian@dlp ~(keystone)$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | 0e6d64ec-54b0-4ffc-89b5-579a62c0e848 | None | IPv4 | 0.0.0.0/0 | | egress | None | None | | 35284802-7475-4a38-bf2f-ff75c16b5f60 | tcp | IPv4 | 0.0.0.0/0 | 22:22 | ingress | None | None | | 71d9a4fb-43f3-49c3-824c-640bd104f8b9 | icmp | IPv4 | 0.0.0.0/0 | | ingress | None | None | | b8efed4d-e612-4151-ad2b-1fc33cfb17b4 | None | IPv6 | ::/0 | | egress | None | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ |
[3] | Login to the instance with SSH. |
debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | ACTIVE | sharednet1=10.0.0.252 | Debian12 | m1.medium | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+debian@dlp ~(keystone)$ ping 10.0.0.252 -c3 PING 10.0.0.252 (10.0.0.252) 56(84) bytes of data. 64 bytes from 10.0.0.252: icmp_seq=1 ttl=64 time=0.670 ms 64 bytes from 10.0.0.252: icmp_seq=2 ttl=64 time=0.494 ms 64 bytes from 10.0.0.252: icmp_seq=3 ttl=64 time=0.421 ms --- 10.0.0.252 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 0.421/0.528/0.670/0.104 msdebian@dlp ~(keystone)$ ssh debian@10.0.0.252
The authenticity of host '10.0.0.252 (10.0.0.252)' can't be established. ED25519 key fingerprint is SHA256:2XW5Ha2H1FT9/+py7+4ZPGL3MFOYEZaruk+iPK908+M. 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.252' (ED25519) to the list of known hosts. Linux debian-12 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. debian@debian-12:~$ # logined |
[4] | If you'd like to stop an instance, it's possible to control with openstack command like follows. |
debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | ACTIVE | sharednet1=10.0.0.252 | Debian12 | m1.medium | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ # stop instance debian@dlp ~(keystone)$ openstack server stop debian-2004 debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+---------+-----------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+---------+-----------------------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | SHUTOFF | sharednet1=10.0.0.252 | Debian12 | m1.medium | +--------------------------------------+-----------+---------+-----------------------+----------+-----------+ # start instance debian@dlp ~(keystone)$ openstack server start debian-2004 debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | ACTIVE | sharednet1=10.0.0.252 | Debian12 | m1.medium | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ |
[5] | It's possible to access with Web browser to get VNC console. |
debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+ | 66f3eed0-9b19-4260-88ce-fb640ca55256 | Debian-12 | ACTIVE | sharednet1=10.0.0.252 | Debian12 | m1.medium | +--------------------------------------+-----------+--------+-----------------------+----------+-----------+debian@dlp ~(keystone)$ openstack console url show Debian-12 +----------+-----------------------------------------------------------------------------------------------+ | Field | Value | +----------+-----------------------------------------------------------------------------------------------+ | protocol | vnc | | type | novnc | | url | https://dlp.srv.world:6080/vnc_auto.html?path=%3Ftoken%3D7a111e85-d19f-4b2c-bf9c-e908f7ae5111 | +----------+-----------------------------------------------------------------------------------------------+ |
[6] | Access to the URL which was displayed by the command above. |
Sponsored Link |
|