OSC OWL Lab "Stable": Openstack VM Creation
Introduction:
OSC Cosmos lab "stable" setup contains 3 machines,
More details about the servers can be found here.
Openstack installed on these machines. Openstack cli is accessible from srv8.osc.cosmos-lab.org.
Openstack credentials are stored in the /home/native/oscadmin-openrc.sh file on srv8.osc.cosmos-lab.org.
Depends on the quota configuration, any number of VMs can be created on these machines.
Steps to create a VM
Load the Openstack credentials
source oscadmin-openrc.shDownload the ubuntu 22.04 image. (Any other image can be used as well, but this is the recommended one)
wget https://cloud-images.ubuntu.com/releases/jammy/release/ubuntu-22.04-server-cloudimg-amd64.imgCreate a new image in OpenStack
openstack image create <NAME_OF_THE_IMAGE> \
--disk-format qcow2 \
--container-format bare \
--file <NAME/LOCATION_OF_THE_CLOUD_IMG> \
--public
# Example
openstack image create "Ubuntu 22.04" \
--disk-format qcow2 \
--container-format bare \
--file ubuntu-22.04-server-cloudimg-amd64.img \
--publicVerify the quota for the project
Quota is the limit on the number of resources that can be created in OpenStack. You can check the quota for your project using,
openstack quota showCreate a new flavour
OpenStack flavours define the compute, memory, and storage capacity of virtual machines.
openstack flavor create <NAME_OF_THE_FLAVOUR> \
--vcpus <VCPU_CPU> \
--ram <RAM_SIZE_IN_MB> \
--disk <DISK_SIZE_IN_GB>
# Example
openstack flavor create m1.20cpu.100gb \
--vcpus 20 \
--ram 51200 \
--disk 100Create a network, subnet, and router
openstack network create <NETWORK_NAME>
#Example
openstack network create smo-lite-netopenstack subnet create <NAME_OF_THE_SUBNET> \
--network <NETWORK_NAME> \
--subnet-range <SUBNET_IP_RANGE> \
--gateway <GATEWAY_IP> \
--dns-nameserver <DNS_IP>
#Example
openstack subnet create smo-lite-subnet \
--network smo-lite-net \
--subnet-range 192.168.100.0/24 \
--gateway 192.168.100.1 \
--dns-nameserver 8.8.8.8openstack router create <ROUTER_NAME>
# Example
openstack router create smo-lite-routeropenstack router add subnet <ROUTER_NAME> <NAME_OF_THE_SUBNET>
# Example
openstack router add subnet smo-lite-router smo-lite-subnetCreate a keypair for SSH access
ssh-keygen -t rsa -b 4096 -f ~/.ssh/<KEY_NAME>
# Example
ssh-keygen -t rsa -b 4096 -f ~/.ssh/smo-lite-keyopenstack keypair create --public-key ~/.ssh/<KEY_NAME>.pub <KEY_NAME>
# Example
openstack keypair create --public-key ~/.ssh/smo-lite-key.pub smo-lite-keyCreate a security group for the VM instance
Default security group is available in OpenStack, but it is recommended to create a new one for better control.
openstack security group create <NAME_OF_THE_SECURITY_GROUP>
# Example
openstack security group create smo-lite-security-groupCreate a VM instance using the created image, flavor, network, and keypair
openstack server create <NAME_OF_THE_SERVER> \
--image <NAME_OF_THE_IMAGE> \
--flavor <NAME_OF_THE_FLAVOUR> \
--network <NAME_OF_THE_NETWORK> \
--security-group <NAME_OF_THE_SECURITY_GROUP> \
--key-name <NAME_OF_THE_KEY>
# Example
openstack server create smo-lite-ubuntu22 \
--image "Ubuntu 22.04" \
--flavor m1.20cpu.100gb \
--network smo-lite-net \
--security-group c00f4925-4a82-4113-b431-92f648267cb6 \
--key-name smo-lite-key