OpenStack Victoria : Create Instances2021/08/31 |
Create and Start Virtual Machine Instance.
|
|
[1] | Login as a common user and create a config for authentication of Keystyone. 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=http://10.0.0.30: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 " >> ~/.bashrc
# confirm available [flavor] list debian@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 debian@dlp ~(keystone)$ openstack image list +--------------------------------------+----------+--------+ | ID | Name | Status | +--------------------------------------+----------+--------+ | 773971b3-b4be-4b07-aa06-fe8ca76b395d | Debian11 | active | +--------------------------------------+----------+--------+ # confirm available network list debian@dlp ~(keystone)$ openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | 487dfa9b-0503-4b4f-be43-83b10853035b | sharednet1 | 823a48aa-5525-421e-b75b-1a1e72fb44c6 | +--------------------------------------+------------+--------------------------------------+ # create a security group for instances debian@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+---------------------------------------------------------------------------+ | Field | Value | +-----------------+---------------------------------------------------------------------------+ | created_at | 2021-08-31T02:50:00Z | | description | secgroup01 | | id | 61304964-7245-48dd-ad73-25ed70d5bb8b | | name | secgroup01 | | project_id | b6ee2add98874535be40eb037884339d | | revision_number | 1 | | rules | created_at='2021-08-31T02:50:00Z', direction='egress', ethertype='I..... | | | created_at='2021-08-31T02:50:00Z', direction='egress', ethertype='I..... | | stateful | True | | tags | [] | | updated_at | 2021-08-31T02:50:00Z | +-----------------+---------------------------------------------------------------------------+debian@dlp ~(keystone)$ openstack security group list +--------------------------------------+------------+------------------------+----------------------------------+------+ | ID | Name | Description | Project | Tags | +--------------------------------------+------------+------------------------+----------------------------------+------+ | 61304964-7245-48dd-ad73-25ed70d5bb8b | secgroup01 | secgroup01 | b6ee2add98874535be40eb037884339d | [] | | 6b10e301-4dbc-4b3a-a443-e5d3330a1033 | default | Default security group | b6ee2add98874535be40eb037884339d | [] | +--------------------------------------+------------+------------------------+----------------------------------+------+ # create a 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 | +-------------+-------------------------------------------------+ | fingerprint | 1a:66:c0:0d:88:2b:d2:58:49:e8:0e:77:3a:f7:8a:25 | | name | mykey | | user_id | 2a7dd329f1434536b12eb0784a9b3b98 | +-------------+-------------------------------------------------+debian@dlp ~(keystone)$ openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 1a:66:c0:0d:88:2b:d2:58:49:e8:0e:77:3a:f7:8a:25 | +-------+-------------------------------------------------+
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.small --image Debian11 --security-group secgroup01 --nic net-id=$netID --key-name mykey Debian-11
+-----------------------------+-------------------------------------------------+ | 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 | B6v5ChSF4qGk | | config_drive | | | created | 2021-08-31T02:52:33Z | | flavor | m1.small (0) | | hostId | | | id | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | | image | Debian11 (773971b3-b4be-4b07-aa06-fe8ca76b395d) | | key_name | mykey | | name | Debian-11 | | progress | 0 | | project_id | b6ee2add98874535be40eb037884339d | | properties | | | security_groups | name='61304964-7245-48dd-ad73-25ed70d5bb8b' | | status | BUILD | | updated | 2021-08-31T02:52:33Z | | user_id | 2a7dd329f1434536b12eb0784a9b3b98 | | volumes_attached | | +-----------------------------+-------------------------------------------------+ # show status ([BUILD] status is shown when building instance) debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+----------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+----------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | BUILD | | Debian11 | m1.small | +--------------------------------------+-----------+--------+----------+----------+----------+ # when starting noramlly, the status turns to [ACTIVE] debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | ACTIVE | sharednet1=10.0.0.205 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ |
[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 | 2021-08-31T02:57:46Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 2fba0220-0563-4584-9765-c624658198ef | | name | None | | port_range_max | None | | port_range_min | None | | project_id | b6ee2add98874535be40eb037884339d | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | 61304964-7245-48dd-ad73-25ed70d5bb8b | | tags | [] | | updated_at | 2021-08-31T02:57:46Z | +-------------------+--------------------------------------+ # permit SSH debian@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2021-08-31T02:58:01Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 1ee565f0-81da-4002-838f-60258578f712 | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | b6ee2add98874535be40eb037884339d | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | 61304964-7245-48dd-ad73-25ed70d5bb8b | | tags | [] | | updated_at | 2021-08-31T02:58:01Z | +-------------------+--------------------------------------+debian@dlp ~(keystone)$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Remote Security Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ | 1ee565f0-81da-4002-838f-60258578f712 | tcp | IPv4 | 0.0.0.0/0 | 22:22 | None | | 2fba0220-0563-4584-9765-c624658198ef | icmp | IPv4 | 0.0.0.0/0 | | None | | 325533f3-67a0-469e-aeac-8189bac78f7f | None | IPv6 | ::/0 | | None | | 545b4d84-b0c1-45d0-907c-a9bc4483558d | None | IPv4 | 0.0.0.0/0 | | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ |
[3] | Login to the instance with SSH. |
debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | ACTIVE | sharednet1=10.0.0.205 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-----------------------+----------+----------+debian@dlp ~(keystone)$ ping 10.0.0.205 -c3 PING 10.0.0.205 (10.0.0.205) 56(84) bytes of data. 64 bytes from 10.0.0.205: icmp_seq=1 ttl=64 time=0.717 ms 64 bytes from 10.0.0.205: icmp_seq=2 ttl=64 time=0.666 ms 64 bytes from 10.0.0.205: icmp_seq=3 ttl=64 time=0.714 ms --- 10.0.0.205 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 0.666/0.699/0.717/0.023 msdebian@dlp ~(keystone)$ ssh debian@10.0.0.205
The authenticity of host '10.0.0.205 (10.0.0.205)' can't be established. ECDSA key fingerprint is SHA256:GvYC5JdZpM4+dYGVJ7EDetYHq9VkuR83F8eeaxaM0ZI. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.0.0.205' (ECDSA) to the list of known hosts. Linux debian-11 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) 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-11:~$ # 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 | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | ACTIVE | sharednet1=10.0.0.205 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ # stop instance debian@dlp ~(keystone)$ openstack server stop Debian-11 debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+---------+-----------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+---------+-----------------------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | SHUTOFF | sharednet1=10.0.0.205 | Debian11 | m1.small | +--------------------------------------+-----------+---------+-----------------------+----------+----------+ # start instance debian@dlp ~(keystone)$ openstack server start Debian-11 debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | ACTIVE | sharednet1=10.0.0.205 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ |
[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 | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | 49b8a773-3df6-42c7-8c91-9a1b8146f50e | Debian-11 | ACTIVE | sharednet1=10.0.0.205 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-----------------------+----------+----------+debian@dlp ~(keystone)$ openstack console url show Debian-11 +-------+------------------------------------------------------------------------------------------+ | Field | Value | +-------+------------------------------------------------------------------------------------------+ | type | novnc | | url | http://10.0.0.30:6080/vnc_auto.html?path=%3Ftoken%3Dfa899197-4749-4849-a5e6-1ea53cb1d9ed | +-------+------------------------------------------------------------------------------------------+ |
[6] | Access to the URL which was displayed by the command above. |
Sponsored Link |