Milestone 9 ‐ OpenStack Tutorials - jacobwilliams100/sys-350 GitHub Wiki

3. Learn about OpenStack services and their functions

Our system meets the recommended specifications.

{5202A173-64D1-4BC9-903F-E1D48E875866}

Services

List registered microstack services with microstack.openstack catalog list

{764CECCA-2C36-4E6D-AF7E-A967996665F3}

Each service has three endpoints:

  • internal provides access for other OpenStack services.
  • admin provides access for the admin project.
  • public provides access for other projects.

Keystone

Microstack uses keystone to manage identities, domains and projects. It is what it uses to handle authentication

To list all users, run microstack.openstack user list

{3BA7791D-E6EB-4A04-B5B7-AB019B9D356A}

Glance

Micostack uses Glance to manage images (templates for provisioning instances)

list all of microstack's instances with microstack.openstack image list

{DF98EC56-21FC-49D4-A12D-D24C385FC630}

CirrOS is already present in Glance

Neutron

Neutron is how MicroStack manages networks and network devices. This includes virtual networks, subnets, routers, and security groups.

To list all of MicroStack's virtual networks, use microstack.openstack network list

{43F5910D-D39B-4DB6-91E4-231E4768ACB1}

Nova

Nova is how MicroStack manages computing resources. It handles scheduling, resource provisioning, and termination.

List all hypervisors managed by Nova with microstack.openstack hypervisor list

{F644843D-FE4D-41C3-9C56-FA624D4BD5E4}

4. Navigate through the OpenStack dashboard menu

The dashboard is how we manage Microstack

Change the theme

Go ahead and sign in to the MicroStack dashboard with your credentials

(if you forget your password, you can retrieve it with sudo snap get microstack config.credentials.keystone-password)

{1BDA2F8D-A942-456B-A3A5-42747A9F6AB5}

Go to Admin->Themes

{78C7424E-B993-41C3-8CD4-7E5FD3E419CF}

Picking a different theme will change the visual appearance of the Dashboard

{53E61F41-A08D-4E25-984E-19BE45D4D4CA}

Change Admin password

Go to admin->Settings

{78C7424E-B993-41C3-8CD4-7E5FD3E419CF}

and on the left bar, click "Change Password"

{51CF86BF-A659-480D-AA2D-A64574EFFCE0}

Here, you can change your password. This is a good idea, because the default one is kind of unwieldy. You will need to log back in afterward.

{EF026448-A76B-4FAB-91B2-7F97A3691120}

Also on this menu, Openstack RC File

{B602EC60-A55D-42DD-BD29-678F1C509C15}

And execute it: source ~/Downloads/admin-openrc.sh

{8E428DDB-3181-4750-9EDF-37A4C6E174E6}

Enter your new password

This is necessary for us to continue managing MicroStack from the command line.

Adding a new admin

(go to the "users" menu on the sidebar)

{195D6485-195F-4E5D-B049-378BE8457B43}

Relog as this new account and repeat the Open RC process:

{C3014CC1-B21A-47B6-8CB8-19F054D919B7}

{52B94117-D0C5-40BB-A129-941A106DE87D}

Navigate through the project menu

Click the "admin" icon in the upper left, and you can see the current project. So far, there are no others.

Click "Project on the left to go to the project menu

{5509C2E3-995C-49BF-8E3E-BE4CFCB6062A}

API Access has to do with API endpoints

Compute has to do with computing resources

Network has to do with networking resources

To list all images for project "admin" go to Project->Compute->Images

{DEF3EF47-2F92-4866-98B1-2E3EC5F8845C}

We only have the Cirros image so far.

Navigate through the admin menu

If we go to Admin->Compute->Hypervisors, we can see all hypervisors. Explore other sections of the Admin menu

{C2E6CB9F-3AA2-4E26-AC64-DAF152C1E8D4}

{393FD556-05C3-4F23-A0C4-FAAFEC081A07}

Navigate through the Identity Menu

The Identity menu (also on the left bar) has 5 sections:

  • Projects (access to project accounts)

  • Users (access to user accounts)

  • Groups (access to user groups)

  • Roles (Access to user roles)

  • Application credentials (access to application credentials)

For example To list all user user roles, go to Identity->Roles

{A9F85288-2804-4F7C-9143-7902B99361BB}

5. Manage instance templates, including images and flavors

Manage Images

Images are roughly equivalent to vcenter's templates. They contain a guest OS and are used for provisioning instances. '

Let's start by downloading the Ubuntu 20.04 LTS image at:

https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-disk-kvm.img?_gl=1*ook7lr*_gcl_au*MzQ0MDkzMzkxLjE3MzAyOTUzMTM.&_ga=2.91766234.1152698332.1730295311-1441464494.1730295311

{C5CDC2BE-B67C-4462-A967-C2770FE39524}

To upload the image to Glance:

microstack.openstack image create --disk-format qcow2 --min-disk 8 --min-ram 512 --file ~/Downloads/focal-server-cloudimg-amd64-disk-kvm.img --private ubuntu-focal

Output should look something like this

{51E6D539-48DD-4D97-BF24-D8304E692B0B}

to list all images, run microstack.openstack image list

{0DF991C7-E1B0-404C-BE74-96B82E607BD8}

As we can see, the ubuntu-focal image was added

Back on the web UI, if we go to Admin->Compute->Images

It is now available here as well

{A4812700-1F73-4ED9-B3D0-1393B76381E6}

You can also upload images using this menu by clicking the "Create Image" button

{D7D2E714-4F91-4E35-968E-74FEED3218BE}

Manage flavors

Flavors are used alongside instances to choose which/how much resources are assigned to a VM. They are equivalent to vcenter's Customization Specifications.

To create a basic flavor, run microstack.openstack flavor create --ram 1024 --disk 10 --vcpus 1 myflavor

{8AA7402F-DA6D-479B-B610-67438CC19FF6}

To list all flavors, run microstack.openstack flavor list

{7DAFA977-8DF3-4C6C-965D-6C23BB8BB365}

As we can see, the new myflavor is now here

We can also create the flavor in the web UI by going to Admin->Compute->Flavors->Create Flavor

{09948504-5EDC-49A8-A1FA-5C09477C5E60}

{63238956-B409-4EE6-AA43-671980F15EA6}

6. Use the concept of domains, roles, users and groups to manage identities

Manage Domains

Domains are high-level collections of projects, groups, and users. They are used for multi-tenancy in MicroStack/OpenStack

We will create a simple domain with microstack.openstack domain create --description "test" newdomain

{754BE311-2660-40DD-9B6F-743670202DC4}

Then list all domains with microstack.openstack domain list

{3B5FBB06-3702-4C68-8045-FE942832D1DC}

We create a new admin user for this domain with:

microstack.openstack user create --domain newdomain --password admin admin

and

microstack.openstack role add --domain newdomain --user-domain newdomain --user admin admin

{C4B0DFFA-7F76-4F79-9F62-FD8C3BCF1E35}

You need to complete an extra step to enable multi-domain to get this to work properly.

sudo bash -c 'cat > /var/snap/microstack/common/etc/horizon/local_settings.d/_10_enable_multidomain_support.py' << EOF

OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = TRUE

EOF

You should now be able to log into the web UI with these credentials

image

Success!

image

Manage Roles

Roles are used for managing RBAC in OpenStack, for domains and projects. All roles are shared across all domains.

Create a new role "member" with microstack.openstack role create _member_

image

List all existing roles with microstack.openstack role list

image

Manage Projects

Projects are used to organize resources such as instances and volumes. One domain can have multiple projects inside.

We will create a project "newproject" in the domain "newdomain" with the following command:

microstack.openstack project create --domain newdomain newproject

image

To list all projects, do microstack.openstack project list --domain newdomain

image

Back on the web interface, go to Identity->Projects and click "Create Project"

image

We can create a project this way too

image

Manage Users and Groups

Users and groups are entities given access to resources within projects and domains (via roles). One domain can contain multiple users and groups.

We will create a new user "newuser" with password "newpassword" within "newdomain" with the command microstack.openstack user create --domain newdomain --password newpassword newuser

image

To list all users in domain "newdomain", run microstack.openstack user list --domain newdomain

image

We will create a new group "newgroup" in domain "newdomain" with microstack.openstack group create --domain newdomain newgroup

image

To list all groups in the domain "newdomain", microstack.openstack group list --domain newdomain

image

Switch to the web UI and go to Identity->Users and click "Create User"

image

We can create a user from this screen too.

image

Whether created from the CLI or GUI, you should be able to see the new user "newuser"

image

Now go to Identity->Groups and click "Create Group"

image

We can create a group from this screen too.

image

Whichever way you created "newuser", it should now be visible on this screen.

image

Manage Membership and Assignments

We will add newuser to newgroup on newdomain with the following command:

microstack.openstack group add user --group-domain newdomain --user-domain newdomain newgroup newuser

image

We will assign the member role to the newgroup group on the newproject project with the following command:

microstack.openstack role add --project newproject --project-domain newdomain --group newgroup --group-domain newdomain member

image

Back on the web UI, go to Identity->Groups, and under actions, click "Manage Members"

image

Notice user "newuser" has been added to the group. Click "Add Users"

image

We can add users to groups from this screen too.

image

Go to Identity->Projects and click "Manage Memebers"

image

Under the "Project Groups" tab, we can add groups to projects

image

Finishing Setting up Admin User

To finish setting up the "admin" user in "newdomain" we need to assign the roles member and admin to this user in the project newproject. Use these commands:

microstack.openstack role add --project newproject --project-domain newdomain --user admin --user-domain newdomain member

microstack.openstack role add --project newproject --project-domain newdomain --user admin --user-domain mydomain admin

image

Back on the web UI, click the dropdown in the upper-left and select newproject

image

To download the RC file, go to Admin->OpenStack RC File

image

image

We will not proceed with executing the file because it caused problems the first time I did this in the tutorial.

7. Multi-tenancy

Enable Multi-Tenancy

OpenStack is multi-tenant by default; Multi-tenancy allows multiple organizations to use the same OpenStack server simultaneously. OpenStack uses its identity features to sort tenant resources. Specifically, using domains, users, groups, and projects.

Microstack will need to have a setting changed to allow for multiple domains. We already did this in part 6, but here is a refresher.

sudo bash -c 'cat > /var/snap/microstack/common/etc/horizon/local_settings.d/_10_enable_multidomain_support.py' << EOF

OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = TRUE

EOF

Each domain has its own set of accounts and roles.

Switch to the User Account

Log into the web UI with the newuser account

image

Download the OpenStack RC File

image

And run it with source ~/Downloads/myproject-openrc.sh

image

Manage Global Resources

In OpenStack, global resources are shared across all projects and domains and can be managed by all users with the "admin" role assigned. Tenent resources are limited to a single project or domain, of which "member" users can manage.

To list all images, execute microstack.openstack image list

NOTE: I could not access this after using the RC file from the last step. So I re-remoted as the default admin user to get this to work again.

image

We can also open the web UI and go to Project->Computer->Images

image

Manage Tenant Resources

We need to install some things to get this to work properly.

Install python3-pip and python 3.10 with sudo apt install python3-pip python3.10-venv -y

{56C961DB-5683-47DA-8DF9-564E14C03704}

startup venv with python3 -m venv venv

{6582CBE7-A270-4E37-BA7E-1710DBBDBE80}

execute venv with source venv/bin/activate

{8EFE9A0C-0797-4DED-A4B1-06C7DA72D99A}

Install openstack client with pip install python-openstackclient

{E5E2B5A3-949C-427A-BAF3-5A4D87A197AB}

executing OpenRC file for newuser with source newproject-openrc.sh

image

Then, create a key pair for this user with openstack --insecure keypair create --private-key ./newkeypair.pem --type ssh newkeypair

image

Back in the web UI, go to Key Pairs in the sidebar and you will see that the key pair has been added!

image

image

8. Networks

Credentials

I tried a really long time to log in and send commands as "newuser" from the CLI and I couldn't get it to work, issue with certificates. So I will simply proceed as the admin account. But I will show tasks as newuser from the web UI where possible.

Display Network Topology

Neutron is how microstack handles network resources. It can set up networks, subnets, virtual routers, floating IPs, and security groups for the sake of setting up robust, fully-featured virtual networks for the virtual machines.

To display network topology in the web UI, go to Project->Network->Network Topology

image

At this moment, we can only see external-network.

Manage Networks and Subnets

In the CLI, we will create a new network called "newnetwork" with the command:

microstack.openstack network create newnetwork

image

To list all networks, use microstack.openstack network list

image

To create a new subnet "newsubnet" on network "newnetwork", run:

microstack.openstack subnet create --network newnetwork --subnet-range 192.168.0.0/24 --allocation-pool start=192.168.0.101,end=192.168.0.200 --dns-nameserver 8.8.8.8 newsubnet

image

To list all subnets, use openstack subnet list

image

On the Web UI, go to Project->Network->Networks and click "Create Network"

image

We can create a network from here as well.

image

Now go to subnet from the top bar, you can create a subnet from this window as well.

image

You define details in the third tab, "Subnet Details"

image

Manage Routers

We will create a new virtual router called "newrouter" with the following command:

microstack.openstack router create newrouter

image

To list all routers, use microstack.openstack router list

image

We will set "external-network" as the gateway for "newrouter" with microstack.openstack router set --external-gateway external newrouter

image

To add "newrouter" to "newsubnet", use microstack.openstack router add subnet newrouter newsubnet

image

Go to the web UI and go to Project->Network->Routers and Click "Create Router"

image

We can create a router from here too.

image

It should now be available in Neutron

image

Click on its name and go to the interfaces tab, and click "Add Interface"

image

We can use this screen to add newnetwork (with newsubnet) to the router

The new interface should now be in Neutron's database

image

image

Manage Floating IPs

To allocate a floating IP, use the command "microstack.openstack floating ip create external"

image

List all floating IPs with microstack.openstack floating ip list

image

In the Web UI, go to Project->Network->Floating IPs, click "Allocate IP to Project"

image

From this screen, you may allocate an IP from a virtual network.

image

It will now be available in the Neutron database.

image

Manage Security Groups

We will create a new security group with the command: microstack.openstack security group create newsecuritygroup

image

To list all security groups, use microstack.openstack security group list

image

We will add a simple rule to the security group with:

microstack.openstack security group rule create --remote-ip 0.0.0.0/0 --dst-port 22:22 --protocol tcp --ingress newsecuritygroup

image

To list all rules in the security group, use microstack.openstack security group rule list newsecuritygroup

image

On the web UI, go to Project->Network->Security Groups and click "Create Security Group"

image

We can create a security group from here too.

image

Notice the list has populated with default rules. Click "Add Rule" to change it up

image

We can create Security Group rules here too.

image

The new rule should now be visible.

image

9. Instances

Credentials

Once again, I cannot get credentials to work properly other than the default admin from the CLI so I will simply use that. I will try to show commands on the web UI as myuser whenever possible.

Launch Instances

We will create a simple ubuntu-focal instance "newinstance" on "newnetwork" with the following command:

microstack.openstack --insecure server create --flavor myflavor --image ubuntu-focal --network newnetwork --key-name newkeypair --min 2 --max 2 newinstance

NOTE: I had to manually create newkeypair in here to get this to work

image

image

Launching takes a minute. Wait a second, and then view all instances with microstack.openstack server list

image

Notice, the new instances are here.

Now on the Web UI, go to Project->Computer->Instances, click "Launch Instance"

image

We can create instances from here too! Set these settings and leave the rest default

image

image

image

Then click "Launch Instance" It will take a second to spin up the new instances, but they should load after a bit and be available in the Instances page.

image

Associate Floating IP

We use the following commands to associate a floating IP with newinstance-1

IP=$(microstack.openstack floating ip list | tail -n 2 | head -n 1 | awk '{print $4}')

and

microstack.openstack server add floating ip newinstance-1 $IP

image

image

On the Web UI, go to Project->Compute->Instances and for newinstance-1, go to Actions->Associate Floating IP

image

From here, you can associate a floating IP Address with an instance

image

Notice, newinstance-1 now has this IP address

image

Attach Security Group

Before we do anything with SSH, we must narrow down the default permissions of the key newkeypair.pem. Do this with: chmod 0400 newkeypair.pem

image

To attempt SSH into the instance, use:

IP=$(microstack.openstack floating ip list | tail -n 2 | head -n 1 | awk '{print $4}')

and

ssh -i ~/Downloads/newkeypair.pem -o ubuntu@$IP

image

For some reason it worked perfectly the first time, which shouldn't be true because the default security group does not allow ingress SSH. This may be because we are the admin user. So we will pretend it failed and make the required changes to the security group.

Run: microstack.openstack server add security group newinstance-1 newsecuritygroup

image

Open the web UI and go to Project->Computer->Instances and for newinstance-1, go to Actions->Edit Security Groups

image

We will add newsecuritygroup from All Security Groups and Save.

image

Access Instances

Try again to SSH into newinstance-1

image

It worked!

Disconnect with exit

image

Delete Instances

To delete newinstance-2, use microstack.openstack server delete newinstance-2

image

In the Web UI, go to Project->Computer->Instances and for myinstance-1, go to Actions->Delete Instance

image

I deleted both of them and now they are gone.

image

Reflection

I thought this was a pretty good way to learn about The basic functionality of OpenStack. It contained a decent theoretical explanation of the different services that allow OpenStack to function properly. However, it is clear that these tutorials do not 100% carry over to MicroStack, and at times I felt like I was fighting the program to complete tasks that seemed like they should have been simple. Examples of this include changing CLI user with OpenRC files and enabling multi-domain support. I think that Ubuntu should create a version of this tuorial for MicroStack specifically. Lastly, I enjoyed learning about how to handle virtualization tasks from a command line interface (as opposed to vCenter's GUI) because it opens the potential for shell scripting.