OpenStack Yoga : Create Instances2022/04/29 |
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. |
ubuntu@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)\$ '
ubuntu@dlp:~$
chmod 600 ~/keystonerc ubuntu@dlp:~$ source ~/keystonerc ubuntu@dlp ~(keystone)$ echo "source ~/keystonerc " >> ~/.bash_profile
# confirm available [flavor] list ubuntu@dlp ~(keystone)$ openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.small | 2048 | 10 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+ # confirm available image list ubuntu@dlp ~(keystone)$ openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 70f856cc-6f3a-4cc3-b576-53f829a6d714 | Ubuntu2204 | active | +--------------------------------------+------------+--------+ # confirm available network list ubuntu@dlp ~(keystone)$ openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | 26ede8d3-2d7b-4ca4-890e-91baa511cb23 | sharednet1 | 5c5f9c00-56a6-47dd-a4fb-00635b96b625 | +--------------------------------------+------------+--------------------------------------+ # create a security group for instances ubuntu@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+---------------------------------------------------------------------------+ | Field | Value | +-----------------+---------------------------------------------------------------------------+ | created_at | 2022-04-29T05:58:16Z | | description | secgroup01 | | id | e2db9ce5-fdff-43f8-bec8-601074d64483 | | name | secgroup01 | | project_id | 66102fdb888d4556a59dcff8b631ffdf | | revision_number | 1 | | rules | created_at='2022-04-29T05:58:16Z', direction='egress', ethertype='IPv4... | | | created_at='2022-04-29T05:58:16Z', direction='egress', ethertype='IPv6... | | stateful | True | | tags | [] | | updated_at | 2022-04-29T05:58:16Z | +-----------------+---------------------------------------------------------------------------+ubuntu@dlp ~(keystone)$ openstack security group list +--------------------------------------+------------+------------------------+----------------------------------+------+ | ID | Name | Description | Project | Tags | +--------------------------------------+------------+------------------------+----------------------------------+------+ | 6246af22-c6a0-44f8-9727-660ff794f94c | default | Default security group | 66102fdb888d4556a59dcff8b631ffdf | [] | | e2db9ce5-fdff-43f8-bec8-601074d64483 | secgroup01 | secgroup01 | 66102fdb888d4556a59dcff8b631ffdf | [] | +--------------------------------------+------------+------------------------+----------------------------------+------+ # 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_rsa): # add public-key ubuntu@dlp ~(keystone)$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | created_at | None | | fingerprint | c5:70:c6:06:af:7d:e2:3a:26:e3:87:21:67:cf:db:50 | | id | mykey | | is_deleted | None | | name | mykey | | type | ssh | | user_id | 74a373164921492ca35d32fea0fd2d86 | +-------------+-------------------------------------------------+ubuntu@dlp ~(keystone)$ openstack keypair list +-------+-------------------------------------------------+------+ | Name | Fingerprint | Type | +-------+-------------------------------------------------+------+ | mykey | c5:70:c6:06:af:7d:e2:3a:26:e3:87:21:67:cf:db:50 | ssh | +-------+-------------------------------------------------+------+
ubuntu@dlp ~(keystone)$
netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }') # create and boot an instance ubuntu@dlp ~(keystone)$ openstack server create --flavor m1.small --image Ubuntu2204 --security-group secgroup01 --nic net-id=$netID --key-name mykey Ubuntu-2204
+-----------------------------+---------------------------------------------------+ | 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 | 2F5sx8ZZsx7o | | config_drive | | | created | 2022-04-29T05:59:59Z | | flavor | m1.small (0) | | hostId | | | id | 770bd30c-9e9f-448c-8916-0bbc37027b84 | | image | Ubuntu2204 (70f856cc-6f3a-4cc3-b576-53f829a6d714) | | key_name | mykey | | name | Ubuntu-2204 | | progress | 0 | | project_id | 66102fdb888d4556a59dcff8b631ffdf | | properties | | | security_groups | name='e2db9ce5-fdff-43f8-bec8-601074d64483' | | status | BUILD | | updated | 2022-04-29T05:59:59Z | | user_id | 74a373164921492ca35d32fea0fd2d86 | | volumes_attached | | +-----------------------------+---------------------------------------------------+ # show status ([BUILD] status is shown when building instance) ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+--------+----------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+----------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | BUILD | | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+----------+------------+----------+ # when starting normally, the status turns to [ACTIVE] ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | ACTIVE | sharednet1=10.0.0.231 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ |
[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 | +-------------------------+--------------------------------------+ | created_at | 2022-04-29T06:00:57Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 71341102-cc0a-4ca8-bb9c-6e44f3a94afb | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 66102fdb888d4556a59dcff8b631ffdf | | 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 | e2db9ce5-fdff-43f8-bec8-601074d64483 | | tags | [] | | tenant_id | 66102fdb888d4556a59dcff8b631ffdf | | updated_at | 2022-04-29T06:00:57Z | +-------------------------+--------------------------------------+ # permit SSH ubuntu@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2022-04-29T06:01:17Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | cde11885-898c-4e54-ac4a-f567b62b94ce | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 66102fdb888d4556a59dcff8b631ffdf | | 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 | e2db9ce5-fdff-43f8-bec8-601074d64483 | | tags | [] | | tenant_id | 66102fdb888d4556a59dcff8b631ffdf | | updated_at | 2022-04-29T06:01:17Z | +-------------------------+--------------------------------------+ubuntu@dlp ~(keystone)$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | 71341102-cc0a-4ca8-bb9c-6e44f3a94afb | icmp | IPv4 | 0.0.0.0/0 | | ingress | None | None | | cde11885-898c-4e54-ac4a-f567b62b94ce | tcp | IPv4 | 0.0.0.0/0 | 22:22 | ingress | None | None | | d8d584ea-9e93-42ff-92df-810ca6c7df60 | None | IPv4 | 0.0.0.0/0 | | egress | None | None | | e58bf701-1712-4b64-93a7-cedc3aabb1e8 | None | IPv6 | ::/0 | | egress | None | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ |
[3] | Login to the instance with SSH. |
ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | ACTIVE | sharednet1=10.0.0.231 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ubuntu@dlp ~(keystone)$ ping 10.0.0.231 -c3 PING 10.0.0.231 (10.0.0.231) 56(84) bytes of data. 64 bytes from 10.0.0.231: icmp_seq=1 ttl=64 time=2.38 ms 64 bytes from 10.0.0.231: icmp_seq=2 ttl=64 time=0.825 ms 64 bytes from 10.0.0.231: icmp_seq=3 ttl=64 time=0.513 ms --- 10.0.0.231 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2017ms rtt min/avg/max/mdev = 0.513/1.239/2.380/0.816 msubuntu@dlp ~(keystone)$ ssh ubuntu@10.0.0.231
The authenticity of host '10.0.0.231 (10.0.0.231)' can't be established. ED25519 key fingerprint is SHA256:emSa7byfI53HfkJvvRsSfNi8elPG492D52vxfMmrXmQ. 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.231' (ED25519) to the list of known hosts. Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-25-generic x86_64) ..... ..... To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. ubuntu@ubuntu-2204:~$ # 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 | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | ACTIVE | sharednet1=10.0.0.231 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ # stop instance ubuntu@dlp ~(keystone)$ openstack server stop Ubuntu-2004 ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+---------+-----------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+---------+-----------------------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | SHUTOFF | sharednet1=10.0.0.231 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+---------+-----------------------+------------+----------+ # start instance ubuntu@dlp ~(keystone)$ openstack server start Ubuntu-2004 ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | ACTIVE | sharednet1=10.0.0.231 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ |
[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 | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ | 770bd30c-9e9f-448c-8916-0bbc37027b84 | Ubuntu-2204 | ACTIVE | sharednet1=10.0.0.231 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-----------------------+------------+----------+ubuntu@dlp ~(keystone)$ openstack console url show Ubuntu-2204 +----------+-----------------------------------------------------------------------------------------------+ | Field | Value | +----------+-----------------------------------------------------------------------------------------------+ | protocol | vnc | | type | novnc | | url | https://dlp.srv.world:6080/vnc_auto.html?path=%3Ftoken%3D337d040a-dc42-409a-a5b0-3c7838135466 | +----------+-----------------------------------------------------------------------------------------------+ |
[6] | Access to the URL which was displayed by the command above. |
Sponsored Link |