Skip to content

Getting Started with SysEleven OpenStack

Installing and Configuring OpenStack CLI

Please refer to OpenStack API Access for details on how to install and configure the OpenStack CLI.

Provisioning a Simple Server and Giving It Access to the Internet

To get started with SysEleven OpenStack, follow these steps:

1. Create a Network and Subnet

  1. Use the sidebar to navigate to Networks.
  2. Click Create in the list view and fill out the form: - Name: Provide a name for your network (e.g., my-network). - Description: Optionally, add a description. - Ensure the Create Subnet option is toggled on to create a subnet alongside the network. - Subnet Details:
    • Subnet Name: Give a name to your subnet (e.g., my-subnet).
    • Network Address: Specify the IP range for your subnet (e.g., 192.168.1.0/24).
  3. Click Create. Your network and subnet will be available immediately.

Use the openstack commands to create a network and subnet.

# Create a network
openstack network create my-network

# Create a subnet within the network
openstack subnet create --network my-network --subnet-range 192.168.1.0/24 my-subnet

Define your network and subnet resources in your Terraform configuration.

resource "openstack_networking_network_v2" "my_network" {
  name           = "my-network"
  admin_state_up = true
}

resource "openstack_networking_subnet_v2" "my_subnet" {
  name            = "my-subnet"
  network_id      = openstack_networking_network_v2.my_network.id
  cidr            = "192.168.1.0/24"
  ip_version      = 4
  dns_nameservers = ["8.8.8.8", "8.8.4.4"]
}

2. Create an SSH Key

  1. Use the sidebar to navigate to SSH Keys.
  2. Click Create and choose to: - Generate a Key Pair: The system will generate a new key pair for you. - Import Public Key: Use an existing public key from your local machine.
  3. Name your key (e.g., my-key).
  4. Click OK. Your SSH key will be available immediately.

Use the openstack command to create or import an SSH key.

# Generate a new key pair and save the private key
openstack keypair create my-key > my-key.pem
chmod 600 my-key.pem  # Secure your private key

# Or, import an existing public key
openstack keypair create --public-key ~/.ssh/id_rsa.pub my-key

Define an SSH key resource in your Terraform configuration.

resource "openstack_compute_keypair_v2" "my_keypair" {
  name       = "my-key"
  public_key = file("~/.ssh/id_rsa.pub")
}

3. Provision a Server

  1. Navigate to Servers in the sidebar.
  2. Click Create and fill out the necessary details: - Basics:
    • Name: Provide a name for your server (e.g., my-server).
    • Description: Optionally, add a description.
    • Flavor: Select the desired flavor (e.g., m1.small).
    • Source:
    • Choose an image to boot from (e.g., Ubuntu 20.04).
    • Networks:
    • Attach your server to the network you created earlier (e.g., my-network).
    • Key Pair:
    • Select the SSH key you created (e.g., my-key).
  3. Click Create to start provisioning your server.

Use the openstack command to create a server.

# Replace <flavor> and <image> with actual names or IDs
openstack server create \
  --flavor m1.small \
  --image "Ubuntu 20.04" \
  --key-name my-key \
  --network my-network \
  my-server

Define a compute instance resource in your Terraform configuration.

# Fetch the latest Ubuntu image
data "openstack_images_image_v2" "ubuntu" {
  name = "Ubuntu 20.04"
}

# Fetch the desired flavor
data "openstack_compute_flavor_v2" "small" {
  name = "m1.small"
}

resource "openstack_compute_instance_v2" "my_instance" {
  name            = "my-server"
  image_id        = data.openstack_images_image_v2.ubuntu.id
  flavor_id       = data.openstack_compute_flavor_v2.small.id
  key_pair        = openstack_compute_keypair_v2.my_keypair.name
  security_groups = ["default"]

  network {
    uuid = openstack_networking_network_v2.my_network.id
  }
}

4. Associate a Floating IP (Optional for Internet Access)

To allow external access to your server, associate a floating IP.

  1. Navigate to the "Floating IPs" section in the UI.
  2. Click "Allocate IP to Project" to create a new floating IP.
  3. Select the newly created floating IP and choose "Associate" from the actions menu.
  4. In the dialog, select your server and click "Associate".

To allow external access to your server, associate a floating IP.

# Allocate a floating IP from the 'public' network
openstack floating ip create public

# List available floating IPs to get the allocated IP address
openstack floating ip list

# Associate the floating IP with your server
openstack server add floating ip my-server <floating-ip-address>

Replace <floating-ip-address> with the actual floating IP you allocated.

Include resources to create and associate a floating IP in your Terraform configuration.

# Allocate a floating IP
resource "openstack_networking_floatingip_v2" "fip" {
  pool = "public"
}

# Associate the floating IP with your server
resource "openstack_compute_floatingip_associate_v2" "fip_assoc" {
  floating_ip = openstack_networking_floatingip_v2.fip.address
  instance_id = openstack_compute_instance_v2.my_instance.id
}

5. Accessing Your Server

Once your server is running and has a floating IP, you can SSH into it.

Once your server is running and has a floating IP associated:

  1. Navigate to the "Servers" section in the UI.
  2. Find your server in the list and note its floating IP address.
  3. Use an SSH client to connect to the server: - On Linux or macOS, open a terminal and use the ssh command. - On Windows, you can use PuTTY or the built-in OpenSSH client in newer versions.

Example SSH command:

ssh -i path/to/your/private-key.pem ubuntu@<floating-ip-address>

Replace <floating-ip-address> with your server's actual floating IP, and adjust the username (e.g., ubuntu) based on the image you used.

Once your server is running and has a floating IP associated, you can SSH into it using the OpenStack CLI:

# Get the floating IP of your server
FLOATING_IP=$(openstack server show my-server -f value -c addresses | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')

# SSH into the server
ssh -i path/to/your/private-key.pem ubuntu@$FLOATING_IP

Replace path/to/your/private-key.pem with the path to your private key file, and adjust the username (ubuntu) if necessary based on the image you used.

After applying your Terraform configuration and associating a floating IP, you can output the IP address and use it to SSH into your server:

# Output the floating IP
output "server_floating_ip" {
  value = openstack_networking_floatingip_v2.fip.address
}

After running terraform apply, you'll see the floating IP in the output. Use this IP to SSH into your server:

ssh -i path/to/your/private-key.pem ubuntu@<output-floating-ip>

Replace <output-floating-ip> with the IP address from the Terraform output, and adjust the username (ubuntu) if necessary based on the image you used.

Summary

By following these steps, you've:

  1. Created a network and subnet.
  2. Generated or imported an SSH key.
  3. Provisioned a server attached to your network.
  4. (Optionally) Associated a floating IP for external access.
  5. Connected to your server via SSH.

Your server is now ready for use!

Additional Tips

Security Groups

Ensure your security group rules allow SSH access (port 22) from your IP.

  1. Navigate to the "Security Groups" section.
  2. Select the security group associated with your server.
  3. Click "Add Rule" and create a rule allowing inbound TCP traffic on port 22.
# Allow SSH access from any IP (use with caution)
openstack security group rule create --proto tcp --dst-port 22 default
resource "openstack_networking_secgroup_rule_v2" "allow_ssh" {
  direction         = "ingress"
  ethertype         = "IPv4"
  protocol          = "tcp"
  port_range_min    = 22
  port_range_max    = 22
  remote_ip_prefix  = "0.0.0.0/0"
  security_group_id = openstack_compute_secgroup_v2.secgroup_1.id
}

Floating IP Pool

The external network name (public in this example) may vary. Use openstack network list --external to find the correct name.

Cleanup

Remember to delete resources when they're no longer needed to avoid unnecessary charges.

Navigate through the UI to delete each resource (servers, floating IPs, networks, etc.) when no longer needed.

# Delete the server
openstack server delete my-server

# Delete the floating IP
openstack floating ip delete <floating-ip-address>

# Delete the key pair
openstack keypair delete my-key

# Delete the subnet
openstack subnet delete my-subnet

# Delete the network
openstack network delete my-network

Simply run terraform destroy to remove all resources defined in your Terraform configuration.

Troubleshooting

  • SSH Permission Denied: Ensure your private key has correct permissions (chmod 600 my-key.pem) and you're using the correct username.
  • Resource Quotas: If you encounter quota issues, you may need to request quota increases from SysEleven support.
  • Security Group Rules: Double-check that your security groups allow the necessary ingress and egress traffic.

References