Create multiple cloud servers via OpenStack CLI
Use the --debug flag in OpenStack CLI commands to enable displaying debug information when executing 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.
-
Optional: configure OpenStack CLI.
-
Optional: add an SSH key to the service user.
1. Optional: configure OpenStack CLI
Use the Configure OpenStack CLI using OS tools or Configure OpenStack CLI in a Docker container subsection of the OpenStack CLI instructions.
If you have already configured 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.
-
In the control panel, on the top menu, click IAM.
-
Go to the Service Users section.
-
Open the service user page → Access tab.
-
In the SSH Keys row, click Add key.
-
Enter the key name.
-
In the Public key field, paste the public key you created in step 1.
-
Click Add.
3. Create a private network and subnet
-
Open the CLI.
-
Create a private network:
openstack network create <network_name>Specify
<network_name>— the private network name. -
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 configuration. 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 you created in step 2;<subnet_name>— private subnet name.
4. Create a cloud router connected to the internet
-
Create a cloud router:
openstack router create <router_name>Specify
<router_name>— cloud router name. -
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>— ID or name of the cloud router you created in step 1.
5. Connect a subnet to the cloud router
-
Connect the subnet to the cloud router:
openstack router add subnet <router> <subnet>Specify:
<router>— ID or name of the cloud router you created in step 5;<subnet>— ID or name of the private subnet you created in step 4.
6. Add ports for servers to the subnet
-
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, or the global router network, that you created in step 4. You can view the list of networks using theopenstack network list;<subnet>— ID or name of the subnet you created in step 4. You can view the list of subnets using theopenstack subnet list;<port_ip_address>— port IP address;<port_name>— port name.
-
Repeat step 1 to create ports for each new cloud server.
7. Create cloud servers
-
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-built or custom image. The<image>parameter is the image ID or name. The image must be in the same pool as the server. You can view the list of images using theopenstack image list;--volume <volume>— to create a server from a network volume. The<volume>parameter is the disk ID or name. The disk must be in the same pool segment as the server. You can view the list of network volumes using theopenstack volume list;--snapshot <snapshot>— to create a server from a snapshot. The<snapshot>parameter is the snapshot ID or name. The snapshot must be in the same pool segment as the server. You can view the list of snapshots using theopenstack snapshot list;
<flavor>— flavor ID or name. Flavors correspond to cloud server configurations and define the number of vCPUs, RAM, and the local disk size (optional) of the server. You can use fixed configuration flavors or create a flavor. For example,1013is the ID for creating a server with a fixed configuration from the Standard line with 2 vCPUs and 4 GB RAM in the ru-3 pool. You can view the list of flavors using theopenstack flavor listor in the List of fixed configuration flavors in all pools;<pool_segment>— pool segment in which the cloud server will be created, for example,ru-9a. The list of available pool segments can be checked in the Availability Matrix;<port_uuid>— ID of the port you created in step 7. You can view the list of ports using theopenstack port list;<security_group>— ID or name of the security group to be assigned to all server ports. To create a server with a security group, traffic filtering (port security) must be enabled in the network. You can view the list of groups using theopenstack security group list;<key_name>— name of the public SSH key for the service user you added in step 2. You can view the list of keys using theopenstack keypair list;- optional:
--block-device-mapping vdb=<extra_volume>— ID or name of an additional disk. You can view the list of disks using theopenstack volume list; - optional:
--property x_cloud_smt_enabled=false— disable Hyper-Threading (SMT). If this parameter is not specified, Hyper-Threading (SMT) will be 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 in all pools; - optional:
--property x_cloud_numa_nodes=1— resource allocation on one 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 in all pools; - optional:
--tag <tag_name> --os-compute-api-version 2.52— a tag for adding additional information about the server; - optional:
--tag preemptible --os-compute-api-version 2.72— a tag for creating a preemptible server; - optional:
--user-data <user_data.file>— path to a script with Base64-encoded data. Tasks and commands from the script will be executed at the first OS boot. Examples of scripts can be found in the User data instructions; <server_name>— server name.
- source type:
-
Repeat step 1 to create the required number of servers.
8. Create public floating IP addresses
-
Create a public floating IP address:
openstack floating ip create external-network -
Repeat step 1 to create public floating IP addresses for all cloud servers.
9. Connect public floating IP addresses to cloud servers
-
Connect a public floating IP address to a cloud server port:
openstack floating ip set --port <port> <floating_ip_address>Specify:
<port>— the cloud server port ID you added in step 7;<floating_ip_address>— ID or public floating IP address you created in step 9. You can view the list of public floating IP addresses using theopenstack floating ip list command.
-
Repeat step 1 to connect public floating IP addresses to all cloud servers.