Skip to main content

Create multiple cloud servers via OpenStack CLI

Use the --debug flag in OpenStack CLI commands to enable displaying debug information when running commands. The flag outputs full requests to the OpenStack API, server responses, and internal command execution steps. This helps diagnose issues with authentication, configuration, or interaction with OpenStack services.

  1. Optional: configure the OpenStack CLI.

  2. Optional: add an SSH key to the service user.

  3. Create a private network and subnet.

  4. Create a cloud router connected to the internet.

  5. Connect the private network to the cloud router.

  6. Create ports for cloud servers.

  7. Create cloud servers.

  8. Create public Floating IP addresses.

  9. Connect public Floating IP addresses to cloud servers.

1. Optional: configure OpenStack CLI

Use the Configure OpenStack CLI with OS tools or Configure OpenStack CLI in a Docker container⁠ section of the OpenStack CLI instructions.

If you have already configured the OpenStack CLI, run it.

2. Optional: add a public SSH key to the service user

If an SSH key has already been added to the service user you are using to authorize in the OpenStack API, skip this step.

  1. Create an SSH key.

  2. In the Control panel, in the top menu, click IAM.

  3. Go to Service Users.

  4. Open the service user page → Access tab.

  5. In the SSH keys row, click Add key.

  6. Enter the key name.

  7. In the Public key field, paste the public key that you created in step 1.

  8. Click Add.

3. Create a private network and subnet

  1. Open the CLI.

  2. Create a private network:

    openstack network create <network_name>

    Specify <network_name> — the private network name.

  3. Create a subnet in the private network:

    openstack subnet create \
    --subnet-range <cidr> \
    <dhcp> \
    --gateway <gateway> \
    --network <network> \
    <subnet_name>

    Specify:

    • <cidr> — CIDR of the private subnet, for example 192.168.0.0/24;
    • <dhcp> — DHCP option setting. Specify one of the values:
      • --dhcp — enable DHCP;
      • --no-dhcp — disable DHCP;
    • <gateway> — IP address of the default gateway, for example 192.168.0.1;
    • <network> — ID or name of the private network that you created in step 2;
    • <subnet_name> — private subnet name.

4. Create a cloud router connected to the internet

  1. Create a cloud router:

    openstack router create <router_name>

    Specify <router_name> — the cloud router name.

  2. Optional: connect the cloud router to the internet — an external IP address will be allocated for the router:

    openstack router set --external-gateway external-network <router>

    Specify <router> — the ID or name of the cloud router that you created in step 1.

5. Connect a subnet to the cloud router

  1. Connect the subnet to the cloud router:

    openstack router add subnet <router> <subnet>

    Specify:

6. Add ports for servers to the subnet

  1. Create a port in the subnet:

    openstack port create \
    --network <network> \
    --fixed-ip subnet=<subnet>,ip-address=<port_ip_address> \
    <port_name>

    Specify:

    • <network> — ID or name of the private network that you created in step 4. You can view the list of networks using the command openstack network list;
    • <subnet> — ID or name of the subnet that you created in step 4. You can view the list of subnets using the command openstack subnet list;
    • <port_ip_address> — port IP address;
    • <port_name> — port name.
  2. Repeat step 1 to create ports for each new cloud server.

7. Create cloud servers

  1. Create a cloud server:

    openstack server create \
    [--image <image> | --volume <volume> | --snapshot <snapshot>] \
    --flavor <flavor> \
    --availability-zone <pool_segment> \
    --nic port-id=<port_uuid> \
    --security-group <security_group> \
    --key-name <key_name> \
    <server_name>

    Specify:

    • source type:
      • --image <image> — to create a server from a pre-configured or custom image. The parameter <image> is the ID or name of the image. The image must be located in the same pool as the server. You can view the list of images using the command openstack image list;
      • --volume <volume> — to create a server from a network volume. The parameter <volume> is the ID or name of the volume. The volume must be located in the same pool segment as the server. You can view the list of network volumes using the command openstack volume list;
      • --snapshot <snapshot> — to create a server from a snapshot. The parameter <snapshot> is the ID or name of the snapshot. The snapshot must be located in the same pool segment as the server. You can view the list of snapshots using the command openstack snapshot list;
    • <flavor> — ID or name of the flavor. Flavors correspond to cloud server configurations and determine the number of vCPUs, RAM, and local disk size (optional) of the server. You can use fixed configuration flavors or create a flavor. For example, 1013 is the ID for creating a server with a Standard line fixed configuration with 2 vCPUs and 4 GB RAM in the ru-3 pool. You can view the list of flavors using the command openstack flavor list or in the List of fixed configuration flavors across all pools table;
    • <pool_segment> — the pool segment where the cloud server will be created, for example ru-9a. You can view the list of available pool segments in the Product availability by location instructions;
    • <port_uuid> — ID of the port that you created in step 7. You can view the list of ports using the command openstack port list;
    • <security_group> — ID or name of the security group that will be assigned to all server ports. To create a server with a security group, traffic filtering (port security) must be enabled on the network. You can view the list of groups using the command openstack security group list;
    • <key_name> — name of the public SSH key for the service user that you added in step 2. You can view the list of keys using the command openstack keypair list;
    • optional: --block-device-mapping vdb=<extra_volume> — ID or name of the additional volume. You can view the list of volumes using the command openstack volume list;
    • optional: --property x_cloud_smt_enabled=false — disabling Hyper-Threading (SMT). If the parameter is not specified, Hyper-Threading (SMT) is enabled by default. Can only be used with flavors that support dedicated cores. You can view the list of flavors in the List of fixed configuration flavors across all pools table;
    • optional: --property x_cloud_numa_nodes=1 — allocating resources on a single NUMA node. Can only be used with flavors that support dedicated cores. You can view the list of flavors in the List of fixed configuration flavors across all pools table;
    • optional: --tag <tag_name> --os-compute-api-version 2.52 — a tag to add additional information about the server;
    • optional: --tag preemptible --os-compute-api-version 2.72 — tag for creating a preemptible server;
    • optional: --user-data <user_data.file> — path to the script with Base64-encoded data. Scenarios and tasks from the script will run upon the first boot of the operating system. You can view script examples in the User data instructions;
    • <server_name> — server name.
  2. Repeat step 1 to create the required number of servers.

8. Create public floating IP addresses

  1. Create a public floating IP address:

    openstack floating ip create external-network
  2. Repeat step 1 to create public floating IP addresses for all cloud servers.

9. Connect public floating IP addresses to cloud servers

  1. Connect a public floating IP address to a cloud server port:

    openstack floating ip set --port <port> <floating_ip_address>

    Specify:

    • <port> — ID of the cloud server port that you added in step 7;
    • <floating_ip_address> — ID or public Floating IP address that you created in step 9. You can view the list of public Floating IP addresses using the command openstack floating ip list.
  2. Repeat step 1 to connect public floating IP addresses to all cloud servers.