Launch an instance

Launch an instance

This section creates the necessary virtual networks to support launching instances. Networking option 1 includes one provider (external) network with one instance that uses it. Networking option 2 includes one provider network with one instance that uses it and one self-service (private) network with one instance that uses it. The instructions in this section use command-line interface (CLI) tools on the controller node. For more information on the CLI tools, see the OpenStack End User Guide. To use the dashboard, see the OpenStack End User Guide.

Create virtual network (nova-network)

Create the appropriate networks for your environment, you can continue preparing the environment to launch an instance.

$ nova network-create vmnet \
   --fixed-range-v4 10.0.0.0/16 --fixed-cidr 10.0.20.0/24 --bridge br100

Create m1.nano flavor

The smallest default flavor consumes 512 MB memory per instance. For environments with compute nodes containing less than 4 GB memory, we recommend creating the m1.nano flavor that only requires 64 MB per instance. Only use this flavor with the CirrOS image for testing purposes.

$ openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano

+----------------------------+---------+
| Field                      | Value   |
+----------------------------+---------+
| OS-FLV-DISABLED:disabled   | False   |
| OS-FLV-EXT-DATA:ephemeral  | 0       |
| disk                       | 1       |
| id                         | 0       |
| name                       | m1.nano |
| os-flavor-access:is_public | True    |
| ram                        | 64      |
| rxtx_factor                | 1.0     |
| swap                       |         |
| vcpus                      | 1       |
+----------------------------+---------+

Generate a key pair

Most cloud images support public key authentication rather than conventional password authentication. Before launching an instance, you must add a public key to the Compute service.

  1. Source the demo project credentials:

    $ . demo-openrc
    
  2. Generate and add a key pair:

    $ ssh-keygen -q -N ""
    $ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
    
    +-------------+-------------------------------------------------+
    | Field       | Value                                           |
    +-------------+-------------------------------------------------+
    | fingerprint | ee:3d:2e:97:d4:e2:6a:54:6d:0d:ce:43:39:2c:ba:4d |
    | name        | mykey                                           |
    | user_id     | 58126687cbcc4888bfa9ab73a2256f27                |
    +-------------+-------------------------------------------------+
    

    Note

    Alternatively, you can skip the ssh-keygen command and use an existing public key.

  3. Verify addition of the key pair:

    $ openstack keypair list
    
    +-------+-------------------------------------------------+
    | Name  | Fingerprint                                     |
    +-------+-------------------------------------------------+
    | mykey | ee:3d:2e:97:d4:e2:6a:54:6d:0d:ce:43:39:2c:ba:4d |
    +-------+-------------------------------------------------+
    

Add security group rules

By default, the default security group applies to all instances and includes firewall rules that deny remote access to instances. For Linux images such as CirrOS, we recommend allowing at least ICMP (ping) and secure shell (SSH).

  • Add rules to the default security group:

    • Permit ICMP (ping):

      $ openstack security group rule create --proto icmp default
      
      +-------------------+--------------------------------------+
      | Field             | Value                                |
      +-------------------+--------------------------------------+
      | created_at        | 2016-10-05T09:52:31Z                 |
      | description       |                                      |
      | direction         | ingress                              |
      | ethertype         | IPv4                                 |
      | headers           |                                      |
      | id                | 6ee8d630-9803-4d3d-9aea-8c795abbedc2 |
      | port_range_max    | None                                 |
      | port_range_min    | None                                 |
      | project_id        | 77ae8d7104024123af342ffb0a6f1d88     |
      | project_id        | 77ae8d7104024123af342ffb0a6f1d88     |
      | protocol          | icmp                                 |
      | remote_group_id   | None                                 |
      | remote_ip_prefix  | 0.0.0.0/0                            |
      | revision_number   | 1                                    |
      | security_group_id | 4ceee3d4-d2fe-46c1-895c-382033e87b0d |
      | updated_at        | 2016-10-05T09:52:31Z                 |
      +-------------------+--------------------------------------+
      
    • Permit secure shell (SSH) access:

      $ openstack security group rule create --proto tcp --dst-port 22 default
      
      +-------------------+--------------------------------------+
      | Field             | Value                                |
      +-------------------+--------------------------------------+
      | created_at        | 2016-10-05T09:54:50Z                 |
      | description       |                                      |
      | direction         | ingress                              |
      | ethertype         | IPv4                                 |
      | headers           |                                      |
      | id                | 3cd0a406-43df-4741-ab29-b5e7dcb7469d |
      | port_range_max    | 22                                   |
      | port_range_min    | 22                                   |
      | project_id        | 77ae8d7104024123af342ffb0a6f1d88     |
      | project_id        | 77ae8d7104024123af342ffb0a6f1d88     |
      | protocol          | tcp                                  |
      | remote_group_id   | None                                 |
      | remote_ip_prefix  | 0.0.0.0/0                            |
      | revision_number   | 1                                    |
      | security_group_id | 4ceee3d4-d2fe-46c1-895c-382033e87b0d |
      | updated_at        | 2016-10-05T09:54:50Z                 |
      +-------------------+--------------------------------------+
      

Launch an instance

To launch an instance, you must at least specify the flavor, image name, network, security group, key, and instance name.

  1. On the controller node, source the demo credentials to gain access to user-only CLI commands:

    $ . demo-openrc
    
  2. A flavor specifies a virtual resource allocation profile which includes processor, memory, and storage.

    List available flavors:

    $ openstack flavor list
    
    +----+---------+-----+------+-----------+-------+-----------+
    | ID | Name    | RAM | Disk | Ephemeral | VCPUs | Is Public |
    +----+---------+-----+------+-----------+-------+-----------+
    | 0  | m1.nano |  64 |    1 |         0 |     1 | True      |
    +----+---------+-----+------+-----------+-------+-----------+
    

    Note

    You can also reference a flavor by ID.

  3. List available images:

    $ openstack image list
    
    +--------------------------------------+--------+--------+
    | ID                                   | Name   | Status |
    +--------------------------------------+--------+--------+
    | 390eb5f7-8d49-41ec-95b7-68c0d5d54b34 | cirros | active |
    +--------------------------------------+--------+--------+
    

    This instance uses the cirros image.

  4. List available networks:

    $ openstack network list
    
    +--------------------------------------+-------+-------------+
    | ID                                   | Name  | Subnet      |
    +--------------------------------------+-------+-------------+
    | 53a617cf-33f4-439b-b648-1e2288aa526c | vmnet | 10.0.0.0/16 |
    +--------------------------------------+-------+-------------+
    
  5. List available security groups:

    $ openstack security group list
    
    +--------------------------------------+---------+------------------------+----------------------------------+
    | ID                                   | Name    | Description            | Project                          |
    +--------------------------------------+---------+------------------------+----------------------------------+
    | dd2b614c-3dad-48ed-958b-b155a3b38515 | default | Default security group | a516b957032844328896baa01e0f906c |
    +--------------------------------------+---------+------------------------+----------------------------------+
    

    This instance uses the default security group.

  6. Launch the instance:

    Replace NET_ID with the ID of the network.

    $ openstack server create --flavor m1.nano --image cirros \
      --nic net-id=NET_ID --security-group default \
      --key-name mykey instance
    
    +--------------------------------------+-----------------------------------------------+
    | Property                             | Value                                         |
    +--------------------------------------+-----------------------------------------------+
    | OS-DCF:diskConfig                    | MANUAL                                        |
    | OS-EXT-AZ:availability_zone          | nova                                          |
    | OS-EXT-STS:power_state               | 0                                             |
    | OS-EXT-STS:task_state                | scheduling                                    |
    | OS-EXT-STS:vm_state                  | building                                      |
    | OS-SRV-USG:launched_at               | -                                             |
    | OS-SRV-USG:terminated_at             | -                                             |
    | accessIPv4                           |                                               |
    | accessIPv6                           |                                               |
    | adminPass                            | hdF4LMQqC5PB                                  |
    | config_drive                         |                                               |
    | created                              | 2015-09-17T21:58:18Z                          |
    | flavor                               | m1.nano                                       |
    | hostId                               |                                               |
    | id                                   | 93a0ded7-96f8-4265-979a-5090d292a78b          |
    | image                                | cirros (38047887-61a7-41ea-9b49-27987d5e8bb9) |
    | key_name                             | mykey                                         |
    | metadata                             | {}                                            |
    | name                                 | instance                                      |
    | os-extended-volumes:volumes_attached | []                                            |
    | progress                             | 0                                             |
    | security_groups                      | default                                       |
    | status                               | BUILD                                         |
    | tenant_id                            | f5b2ccaa75ac413591f12fcaa096aa5c              |
    | updated                              | 2015-09-17T21:58:18Z                          |
    | user_id                              | 684286a9079845359882afc3aa5011fb              |
    +--------------------------------------+-----------------------------------------------+
    
  7. Check the status of your instance:

    $ openstack server list
    
    +--------------------------------------+----------+--------+-----------------+------------+
    | ID                                   | Name     | Status | Networks        | Image Name |
    +--------------------------------------+----------+--------+-----------------+------------+
    | 93a0ded7-96f8-4265-979a-5090d292a78b | instance | ACTIVE | vmnet=10.0.20.2 | cirros     |
    +--------------------------------------+----------+--------+-----------------+------------+
    

    The status changes from BUILD to ACTIVE when the build process successfully completes.

  8. Access your instance using SSH from the controller node or any host on the provider physical network:

    $ ssh cirros@10.0.20.2
    
    The authenticity of host '10.0.20.2 (10.0.20.2)' can't be established.
    RSA key fingerprint is ed:05:e9:e7:52:a0:ff:83:68:94:c7:d1:f2:f8:e2:e9.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '10.0.20.2' (RSA) to the list of known hosts.
    

Block Storage

If your environment includes the Block Storage service, you can create a volume and attach it to an instance.

Orchestration

If your environment includes the Orchestration service, you can create a stack that launches an instance.

For more information, see the Orchestration installation guide.

Shared File Systems

If your environment includes the Shared File Systems service, you can create a share and mount it in an instance.

For more information, see the Shared File Systems installation guide.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.