OpenStack Caracal : Create Instances2024/05/21 |
Create and Start Virtual Machine Instances. |
|
[1] | Login as a user that you set environment variables for Openstack and then create and start virtual machine instance. |
# confirm available [flavor] list ubuntu@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 | m2.medium | 8192 | 10 | 10 | 4 | True | +----+-----------+------+------+-----------+-------+-----------+ # confirm available image list ubuntu@dlp ~(keystone)$ openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 7620a182-99f2-4132-9c6e-4b2da962b241 | Ubuntu2404 | active | +--------------------------------------+------------+--------+ # confirm available network list ubuntu@dlp ~(keystone)$ openstack network list +--------------------------------+------------+--------------------------------+ | ID | Name | Subnets | +--------------------------------+------------+--------------------------------+ | 8ffae09c-4cf2-4f65-97d4- | sharednet1 | 6f639fb2-8aa7-46f4-8124- | | 8a204e523b7a | | a2eb32d3a8c7 | +--------------------------------+------------+--------------------------------+ # create a security group for instances ubuntu@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+------------------------------------------------------------+ | Field | Value | +-----------------+------------------------------------------------------------+ | created_at | 2024-05-21T01:28:53Z | | description | secgroup01 | | id | bfeb7f29-41e4-4532-a4a9-31f79c567497 | | name | secgroup01 | | project_id | 18ede7365bdc430093e8fd4a90f77369 | | revision_number | 1 | | rules | created_at='2024-05-21T01:28:53Z', direction='egress', | | | ethertype='IPv4', | | | id='24b92da6-fc55-4eb3-8ac4-6f31c6e6c95e', | | | standard_attr_id='20', updated_at='2024-05-21T01:28:53Z' | | | created_at='2024-05-21T01:28:53Z', direction='egress', | | | ethertype='IPv6', | | | id='d62ec0a3-0837-4d33-a368-8e5e675fd0b6', | | | standard_attr_id='21', updated_at='2024-05-21T01:28:53Z' | | shared | False | | stateful | True | | tags | [] | | updated_at | 2024-05-21T01:28:53Z | +-----------------+------------------------------------------------------------+ubuntu@dlp ~(keystone)$ openstack security group list +------------------+------------+------------------+--------------------+------+ | ID | Name | Description | Project | Tags | +------------------+------------+------------------+--------------------+------+ | 6a835325-7c60- | default | Default security | 18ede7365bdc430093 | [] | | 4109-8030- | | group | e8fd4a90f77369 | | | aaf9c6d499d9 | | | | | | bfeb7f29-41e4- | secgroup01 | secgroup01 | 18ede7365bdc430093 | [] | | 4532-a4a9- | | | e8fd4a90f77369 | | | 31f79c567497 | | | | | +------------------+------------+------------------+--------------------+------+ # create an 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_ed25519): # add public-key ubuntu@dlp ~(keystone)$ openstack keypair create --public-key ~/.ssh/id_ed25519.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | created_at | None | | fingerprint | 15:4f:61:7b:45:32:70:bc:55:3e:e6:ef:43:6b:34:06 | | id | mykey | | is_deleted | None | | name | mykey | | type | ssh | | user_id | b9371d015e0d43dca74f29161448ffd2 | +-------------+-------------------------------------------------+ubuntu@dlp ~(keystone)$ openstack keypair list +-------+-------------------------------------------------+------+ | Name | Fingerprint | Type | +-------+-------------------------------------------------+------+ | mykey | 15:4f:61:7b:45:32:70:bc:55:3e:e6:ef:43:6b:34:06 | ssh | +-------+-------------------------------------------------+------+
ubuntu@dlp ~(keystone)$
netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }') # create and start instance ubuntu@dlp ~(keystone)$ openstack server create --flavor m1.small --image Ubuntu2404 --security-group secgroup01 --nic net-id=$netID --key-name mykey Ubuntu-2404
+--------------------------------------+---------------------------------------+ | 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 | 6x3tFrYHBTsM | | config_drive | | | created | 2024-05-21T01:31:59Z | | flavor | m1.small (2) | | hostId | | | id | e499117a-58e4-4c75-9712-836d4fbe5572 | | image | Ubuntu2404 (7620a182-99f2-4132-9c6e- | | | 4b2da962b241) | | key_name | mykey | | name | Ubuntu-2404 | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | project_id | 18ede7365bdc430093e8fd4a90f77369 | | properties | | | security_groups | name='bfeb7f29-41e4-4532-a4a9- | | | 31f79c567497' | | status | BUILD | | updated | 2024-05-21T01:31:59Z | | user_id | b9371d015e0d43dca74f29161448ffd2 | +--------------------------------------+---------------------------------------+ # show status ([BUILD] status is shown when building instance) ubuntu@dlp ~(keystone)$ openstack server list +--------------+-------------+--------+-----------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+-------------+--------+-----------+------------+----------+ | e499117a- | Ubuntu-2204 | BUILD | | Ubuntu2204 | m1.small | | 58e4-4c75- | | | | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+--------+-----------+------------+----------+ # when starting normally, the status turns to [ACTIVE] ubuntu@dlp ~(keystone)$ openstack server list +--------------+-------------+--------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+-------------+--------+---------------+------------+----------+ | e499117a- | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small | | 58e4-4c75- | | | .0.0.219 | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+--------+---------------+------------+----------+ |
[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 | +-------------------------+--------------------------------------+ | belongs_to_default_sg | False | | created_at | 2024-05-21T01:33:41Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | a3fddb94-1c85-4f62-939d-7308b0677126 | | name | None | | normalized_cidr | 0.0.0.0/0 | | port_range_max | None | | port_range_min | None | | project_id | 18ede7365bdc430093e8fd4a90f77369 | | 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 | bfeb7f29-41e4-4532-a4a9-31f79c567497 | | tags | [] | | updated_at | 2024-05-21T01:33:41Z | +-------------------------+--------------------------------------+ # permit SSH ubuntu@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | belongs_to_default_sg | False | | created_at | 2024-05-21T01:34:07Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | ec433a0d-3d18-4878-acaa-ba8281805399 | | name | None | | normalized_cidr | 0.0.0.0/0 | | port_range_max | 22 | | port_range_min | 22 | | project_id | 18ede7365bdc430093e8fd4a90f77369 | | 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 | bfeb7f29-41e4-4532-a4a9-31f79c567497 | | tags | [] | | updated_at | 2024-05-21T01:34:07Z | +-------------------------+--------------------------------------+ubuntu@dlp ~(keystone)$ openstack security group rule list secgroup01 +----------+-------------+-----------+----------+------------+-----------+-----------------------+----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group | +----------+-------------+-----------+----------+------------+-----------+-----------------------+----------------------+ | 24b92da6 | None | IPv4 | 0.0.0.0/ | | egress | None | None | | -fc55- | | | 0 | | | | | | 4eb3- | | | | | | | | | 8ac4- | | | | | | | | | 6f31c6e6 | | | | | | | | | c95e | | | | | | | | | a3fddb94 | icmp | IPv4 | 0.0.0.0/ | | ingress | None | None | | -1c85- | | | 0 | | | | | | 4f62- | | | | | | | | | 939d- | | | | | | | | | 7308b067 | | | | | | | | | 7126 | | | | | | | | | d62ec0a3 | None | IPv6 | ::/0 | | egress | None | None | | -0837- | | | | | | | | | 4d33- | | | | | | | | | a368- | | | | | | | | | 8e5e675f | | | | | | | | | d0b6 | | | | | | | | | ec433a0d | tcp | IPv4 | 0.0.0.0/ | 22:22 | ingress | None | None | | -3d18- | | | 0 | | | | | | 4878- | | | | | | | | | acaa-ba8 | | | | | | | | | 28180539 | | | | | | | | | 9 | | | | | | | | +----------+-------------+-----------+----------+------------+-----------+-----------------------+----------------------+ |
[3] | Login to the instance with SSH. |
ubuntu@dlp ~(keystone)$ openstack server list +--------------+-------------+--------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+-------------+--------+---------------+------------+----------+ | e499117a- | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small | | 58e4-4c75- | | | .0.0.219 | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+--------+---------------+------------+----------+ubuntu@dlp ~(keystone)$ ping 10.0.0.219 -c3 PING 10.0.0.219 (10.0.0.219) 56(84) bytes of data. 64 bytes from 10.0.0.219: icmp_seq=1 ttl=64 time=1.11 ms 64 bytes from 10.0.0.219: icmp_seq=2 ttl=64 time=0.443 ms 64 bytes from 10.0.0.219: icmp_seq=3 ttl=64 time=0.272 ms --- 10.0.0.219 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2013ms rtt min/avg/max/mdev = 0.272/0.607/1.108/0.360 msubuntu@dlp ~(keystone)$ ssh ubuntu@10.0.0.219
The authenticity of host '10.0.0.219 (10.0.0.219)' can't be established. ED25519 key fingerprint is SHA256:bSxv3n3xqTFacKUkkm33Uarf3mnbyC8IKrycTenpMMw. 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.219' (ED25519) to the list of known hosts. Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64) ..... ..... To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. ubuntu@ubuntu-2404:~$ # 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 | +--------------+-------------+--------+---------------+------------+----------+ | e499117a- | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small | | 58e4-4c75- | | | .0.0.219 | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+--------+---------------+------------+----------+ # stop instance ubuntu@dlp ~(keystone)$ openstack server stop Ubuntu-2404 ubuntu@dlp ~(keystone)$ openstack server list +--------------+-------------+---------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+-------------+---------+---------------+------------+----------+ | e499117a- | Ubuntu-2404 | SHUTOFF | sharednet1=10 | Ubuntu2404 | m1.small | | 58e4-4c75- | | | .0.0.219 | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+---------+---------------+------------+----------+ # start instance ubuntu@dlp ~(keystone)$ openstack server start Ubuntu-2404 ubuntu@dlp ~(keystone)$ openstack server list +--------------+-------------+--------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+-------------+--------+---------------+------------+----------+ | e499117a- | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small | | 58e4-4c75- | | | .0.0.219 | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+--------+---------------+------------+----------+ |
[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 | +--------------+-------------+--------+---------------+------------+----------+ | e499117a- | Ubuntu-2404 | ACTIVE | sharednet1=10 | Ubuntu2404 | m1.small | | 58e4-4c75- | | | .0.0.219 | | | | 9712- | | | | | | | 836d4fbe5572 | | | | | | +--------------+-------------+--------+---------------+------------+----------+ubuntu@dlp ~(keystone)$ openstack console url show Ubuntu-2404 +----------+-------------------------------------------------------------------+ | Field | Value | +----------+-------------------------------------------------------------------+ | protocol | vnc | | type | novnc | | url | https://dlp.srv.world:6080/vnc_auto.html?path=%3Ftoken%3Dd8e8dcd4 | | | -8368-408c-83f7-e38dd2299f77 | +----------+-------------------------------------------------------------------+ |
[6] | Access to the URL which was displayed by the command above. |
Sponsored Link |