How to create an Instance using OpenStack CLI

background
Reading Time: 3 minutes

Prerequisites:

For creating your OpenStack instance using CLI, you must have installed OpenStack in your system.

I have successfully installed my OpenStack you can use the command to see all the information about OpenStack.

sudo snap info microstack

Overview:

  • Instance source — Can be an image, snapshot, or block storage volume that contains an image or snapshot.
  • Instance name — The name for your instance.
  • Flavor — The flavor for your instance defines the vCPU and RAM memory limits for instance.
  • Access and security credentials — This includes one or both of the following credentials:
    • keypair — These are SSH credentials that are injected into images when they are launched. For the key pair to be successfully injected, the image must contain the cloud-init package. Create at least one key pair for each project. If you already have generated a key pair with an external tool, you can import it into DreamCompute. You can use the key pair for multiple instances that belong to that project.
    • Security group — Defines which incoming and outgoing network traffic is forwarded to and from the instances. Security groups hold a set of firewall policies, known as security group rules.
  • IP addresses — If needed, you can assign a floating (public) IP address to a running instance.

Gather parameters to create an instance:

Using some steps/commands to gather the parameters to launch an instance.

The available flavors:

microstack.openstack flavor list

Note: The ID of the flavor you want to use for your instance:

The available images:

microstack.openstack server list

The available security groups:

microstack.openstack security group list

Available key pairs:

microstack.openstack keypair list

Launch an instance from an image:

After you’ve gathered the required parameters, you can now create an Instance. At this point, you should have the following credentials:

  • flavor — m1.large
  • image — ubuntu (e579edda-9972-450f-ac20-d5cb8d5f1d45)
  • keypair — microstack
  • security group — e9cd89d8-ffdd-4712-943e-f7a0ea1cefe1
  • Network Id — ea8d3e99-e555-4854-b461-b6824095898e
  • server name — User Choice

Run this command to create your instance:

microstack.openstack server create --flavor 4 --image e579edda-9972-450f-ac20-d5cb8d5f1d45  --key-name microstack  --security-group e9cd89d8-ffdd-4712-943e-f7a0ea1cefe1 --nic net-id=ea8d3e99-e555-4854-b461-b6824095898e                   myNewInstance
Instance Launch

Check if the instance is online

Use the list command to view a list of all instances:

microstack.openstack server list
The list shows the ID, Name, Status, IP addresses, Image, and Flavor for all instances in the project.

Reference:

https://docs.openstack.org/

Leave a Reply