Milestone 9 OpenStack Tutorials - Oliver-Mustoe/Oliver-Mustoe-Tech-Journal GitHub Wiki

This page journals content related to SYS-350 milestone 9.

Table of Contents:

Services tutorial

Can see services with:

microstack.openstack catalog list

And can see users:

microstack.openstack user list

List images:

microstack.openstack image list

List the networks:

microstack.openstack network list

List hypervisors:

microstack.openstack hypervisor list

Dashboard tutorial

Can use the dropdown in the OpenStack web gui > to change the theme:

I can also go to "Identity" > "Users":

Then "Create User" > create a new admin user named "oliver":

Logged in as that user:

Can see images in "Project" > "Images":

Can list hypervisors in "Admin" > "Compute" > "Hypervisors":

Can see users in "Identity" > "Users":

Template tutorial

Create images

I downloaded the focal image:

wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-disk-kvm.img

Then I created my image:

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

Image gets created:

I could also create an image from the web gui > "Admin" > "Images":

Then "Create Image":

Create flavors

I could then create my flavor:

microstack.openstack flavor create --ram 1024 --disk 10 --vcpus 1 oliver-flavor

Could also go through the web gui and go to "Admin" > "Compute" > "Flavors":

Then "Create Flavor":

Identities tutorial

Domain management

I created my domain "oliverdomain":

microstack.openstack domain create --description "olivers_domain" oliverdomain

Then I created a admin user "oadmin" and added the admin role (in my domain):

microstack.openstack user create --domain oliverdomain --password <insert_oadmin_password_here> oadmin
microstack.openstack role add --domain oliverdomain --user-domain mydomain --user oadmin admin

I also added the following to "/var/snap/microstack/common/etc/horizon/local_settings.d/_05_snap_tweaks.py" to enable domains:

# Setup multidomain support
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"

Additions seen added to _05_snap_tweaks.py:

Then I ran:

sudo snap restart microstack.horizon-uwsgi

With this I could login as my created user in my domain:

Role management

I could then create a role:

microstack.openstack role create _olivermember_

And could see all roles with:

microstack.openstack role list

Management of projects

I could create a project named "oliverproject" in the domain "oliverdomain":

microstack.openstack project create --domain oliverdomain oliverproject

And then I could list all of the projects in my "oliverdomain":

microstack.openstack project list --domain oliverdomain

A screen shot of a computer Description automatically generated

I could also create a project by logging into my "oliverdomain" as my "oadmin" user on the web gui > "Identity" > "Projects":

A screenshot of a computer Description automatically generated

Then I could press "Create Project" > fill it in with the following information:

A screenshot of a project Description automatically generated

After pressing "Create Project" > project will be created like it was in the command line:

A screenshot of a computer Description automatically generated

User and group management

I created a new user in my "oliverdomain":

microstack.openstack user create --domain oliverdomain --password <insert_oadmin2_password_here> oadmin2

And I created a group in my "oliverdomain":

microstack.openstack group create --domain oliverdomain olivergroup

Listed out groups:

microstack.openstack group list --domain mydomain

A screenshot of a computer Description automatically generated

Membership and assignment management

I could add my "oadmin2" user to the "olivergroup" in the "oliverdomain":

microstack.openstack group add user --group-domain oliverdomain --user-domain oliverdomain olivergroup oadmin2

Then I could assign the oliverproject's "member" role to the "olivergroup":

microstack.openstack role add --project oliverproject --project-domain oliverdomain --group olivergroup --group-domain oliverdomain member

Logged in as oadmin2, can see project:

A screenshot of a computer Description automatically generated

I also can add a user to a group by going to the web gui > "Identity" > "Groups":

A screenshot of a computer Description automatically generated

Then selecting a group ("olivergroup" in this case and selecting "Manage Members"):

A screenshot of a computer Description automatically generated

And finally "Add Users" (no users were added as oadmin2 was already added via cli):

A screenshot of a computer Description automatically generated

I could add a group to a project by going to "Identity" > "Projects":

A screenshot of a computer Description automatically generated

Then pressing "Manage Members" > where I could add users or groups to the project (using the "Project Members" or "Project Groups" tabs):

A screenshot of a computer Description automatically generated

Final Setup

I would add my "oadmin" user to the "oliverproject" as a admin/member:

microstack.openstack role add --project oliverproject --project-domain oliverdomain --user oadmin --user-domain oliverdomain member
microstack.openstack role add --project oliverproject --project-domain oliverdomain --user oadmin --user-domain oliverdomain admin

And after logging in and out I could see I was apart of the project:

A screenshot of a computer Description automatically generated

As well I clicked on "admin" in the upper right corner > "OpenStack RC File" to download the rc file:

A screenshot of a computer Description automatically generated

I would (IN A NEW TERMINAL SESSION) rename that downloaded .sh file and source it, allowing me to be logged in as my "oadmin" user, in the "oliverdomain", in the CLI!:

mv ~/Downloads/oliverproject-openrc.sh ~/Downloads/oliverdomain_oadmin.sh
source ~/Downloads/oliverdomain_oadmin.sh

A screenshot of a computer Description automatically generated

(in Microstack openrc fix for terminal I describe a way to use this with our microstack setup!)

Multi-tenant management

(NOTE: Requires Identities tutorial to be finished as this tutorial uses/references its created domains/projects/roles/users & groups!)

Setting up access to multi-environment

First I set a Python virtual environment for openstack up by installing needed Python libraries:

sudo apt install python3-pip python3.10-venv -y

Then I setup my environment, sourced it, and installed python-openstackclient:

python3 -m venv openstack
source openstack/bin/activate
pip install python-openstackclient

After that I sourced my oadmin2 .sh file:

source ~/Downloads/oliverdomain_oadmin2.sh

Setting up openstack SSH keypair

I then created a openstack SSH keypair with the following:

openstack --insecure keypair create --private-key ./mykeypair.pem --type ssh mykeypair

A screenshot of a computer Description automatically generated

Keypair made:

A screenshot of a computer Description automatically generated

From the web gui I could have gone from "Project" > "Compute" > "Key Pairs":

A screenshot of a computer Description automatically generated

Then pressed "Create Key Pair" and created a SSH keypair (SSH was not selected by default, needed to use dropdown):

A screenshot of a computer Description automatically generated

Could then press "Create Key Pair" to create the key.

Network management

(NOTE: Requires Identities tutorial to be finished as this tutorial uses/references its created domains/projects/roles/users & groups!)

First I made sure I was sourced into my python environment and my oadmin rc file (made in Multi-tenant management):

source ~/openstack/bin/activate
source ~/Downloads/oliverdomain_oadmin2.sh

After setting that up, I went to the web gui and I could navigate to the Network Topology from "Project" > "Network" > "Network Topology":

A computer screen shot of a network Description automatically generated

Create networks and subnets

In the terminal I created my own network:

openstack --insecure network create olivernetwork

A computer screen shot of a black screen Description automatically generated

Listed networks:

I also created a subnet:

openstack --insecure subnet create --network olivernetwork --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 oliversubnet

A black rectangle with white text Description automatically generated

Listed subnets:

I also could have used the web gui and navigated to "Project" > "Network" > "Networks":

A screenshot of a computer Description automatically generated

And used "Create Network" to create my olivernetwork/oliversubnet:

A screenshot of a computer Description automatically generated

A screenshot of a computer Description automatically generated

A screenshot of a computer Description automatically generated

After pressing the blue "Create" button, network would be created!

(FUN FACT: Can create networks with the same name)

A screenshot of a computer Description automatically generated

A screen shot of a computer Description automatically generated

I would delete the web gui created network.

openstack --insecure network delete 07374b42-2d6b-4c9e-a8d1-3976ec000fc3

A computer screen with white text Description automatically generated

Create routers

After that I created a router with:

openstack --insecure router create oliverrouter

"oliverrouter" created with a listing of all routers:

A screenshot of a computer Description automatically generated

Then I set the external gateway as the gateway for "oliverrouter":

openstack --insecure router set --external-gateway external oliverrouter

And attached the router to the "oliversubnet":

openstack --insecure router add subnet oliverrouter oliversubnet

In the web gui I could have gone to "Project" > "Network" > "Routers":

A screenshot of a computer Description automatically generated

Then "Create Router":

A screenshot of a computer Description automatically generated

After selecting the router, I could have gone to the "Interfaces" section > then pressed "Add interface" and chosen my subnet from the subnet dropdown.

Create floating IPs

I allocated a floating IP from the external network with the following:

openstack --insecure floating ip create external

A computer screen shot of a black screen Description automatically generated

And I could list all floating ips as well:

I could have allocated a floating IP by going to the web gui > "Project" > "Network" > "Floating IPs" > pressing "Allocate IP to Project" on the right":

A screenshot of a computer Description automatically generated

After pressing "Allocate IP":

A screenshot of a computer Description automatically generated

Create Security Group

I created a security group:

openstack --insecure security group create oliversecuritygroup

A black screen with white text Description automatically generated

And then I could add a rule to the security group allowsing SSH ingress:

openstack --insecure security group rule create --remote-ip 0.0.0.0/0 --dst-port 22:22 --protocol tcp --ingress oliversecuritygroup

A black screen with white text Description automatically generated

As well I could list out all of the security groups rules:

openstack --insecure security group rule list oliversecuritygroup

I also could have gone to the web gui "Project" > "Network" > "Security Groups". Then used the "Create Security Group" button to make a security group, then selected it and used the "Add Rule" button to add a rule for SSH (selected from the dropdown.)

Instances management

(NOTE: Requires Identities tutorial to be finished as this tutorial uses/references its created domains/projects/roles/users & groups!)

First I made sure I was sourced into my python environment and my oadmin rc file (made in Multi-tenant management):

source ~/openstack/bin/activate
source ~/Downloads/oliverdomain_oadmin2.sh

Launch instances

Then I created 2 cirros instances (used "cirros" instead of "ubuntu" since we did not have a ubuntu image by default and seemingly the instances do not need to have certain capabilities.)

openstack --insecure server create --flavor oliver-flavor --image cirros --network olivernetwork --key-name mykeypair --min 2 --max 2 oliverinstance

A screenshot of a computer Description automatically generated

(Can also see that the instances received IPs above aswell)

I also could have used the web gui by going to "Project" > "Compute" > "Instances" > "Launch Instance" button then filling it out as follows:

  • Under "Details" - fill out instance name and count

  • Under "Source" - choose to create new volume and press UP besides cirros

  • Under "Flavor" - press UP besides oliver-flavor

Associate floating IP to instance

I associated the floating IP to my "oliverinstance-1" I ran the following:

IP=$(openstack --insecure floating ip list | tail -n 2 | head -n 1 | awk '{print $4}')
openstack --insecure server add floating ip oliverinstance-1 $IP

A black screen with white text Description automatically generated

Or I could have gone to the web gui and went to "Project" > "Compute" > "Instances" > dropdown next to "Create Snapshot" on the "Actions" column for "oliverinstance-1" > "Associate Floating IP" > used the dropdown under "IP Address" to select an IP to associate.

Allowing security group to access instance

I added my security group "oliversecuritygroup" (which will allow ingress SSH) to my instance "oliverinstance-1" via the following:

openstack --insecure server add security group oliverinstance-1 oliversecuritygroup

Or I could have gone to the web gui and went to "Project" > "Compute" > "Instances" > dropdown next to "Create Snapshot" on the "Actions" column for "oliverinstance-1" > "Edit Security Groups" > pressed the + button next to "oliversecuritygroup" in "Security Groups" tab > "Save".

Accessing instance

After adding my security group "oliversecuritygroup" to my instance "oliverinstance-1" with openstack --insecure server add security group oliverinstance-1 oliversecuritygroup, I set the permissions on mykepair.pem:

chmod 0400 ~/mykeypair.pem

And could SSH into "oliverinstance-1":

IP=$(openstack --insecure floating ip list | tail -n 2 | head -n 1 | awk '{print $4}')
ssh -i ~/Downloads/mykeypair.pem -o StrictHostKeyChecking=no ubuntu@$IP

Deleting instances

I deleted my "oliverinstance-2" by running the following:

openstack --insecure server delete oliverinstance-2

Or I could have gone in the web gui to "Project" > "Compute" > "Instances" > dropdown next to "Create Snapshot" on the "Actions" column for "oliverinstance-2" > "Delete Instance" > pressed the button to confirm the deletion.

Definitions

Below are copy pasted definitions of terms used for Microstack:

Domain

"Domains are high-level collections of projects, groups and users. They limit the visibility of those identities to other domains. As a result, domains serve as a basis for implementing multi-tenancy in OpenStack." - Ubuntu

Projects

"Projects are an abstraction used by other OpenStack services to group and isolate various types of resources (instances, volumes, and so on). One domain can have multiple projects created inside." - Ubuntu

Troubleshooting

Microstack Domain Fix

I added the following to "/var/snap/microstack/common/etc/horizon/local_settings.d/_05_snap_tweaks.py":

# Setup multidomain support
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"

Additions added to _05_snap_tweaks.py:

A computer screen shot of white text Description automatically generated

Or I could have added just the multidomain support to a new file under "/var/snap/microstack/common/etc/horizon/local_settings.d/_10_enable_multidomain_support.py":

Then I ran:

sudo snap restart microstack.horizon-uwsgi

Source: https://discourse.charmhub.io/t/openstack-microstack-how-to-enable-multidomain-support-for-horizon/4416

Microstack openrc fix for terminal

Turns out that "microstack.openstack" overrides any environment variables you want to set (following is a snippet from a "microstack.openstack -vvv server list" command showing that openstack is still using username and domain variables that does not match up with:)

A screenshot of a computer Description automatically generated

The oadmin2 rc file I sourced for reference (did cut out a line from the screenshot as it was added by me and did not make any differences):

A computer screen with white text Description automatically generated

To get around this you can override the defaults in the cli like the following:

microstack.openstack --os-username "oadmin2" \
--os-project-name "oliverproject" \
--os-project-domain-name "oliverdomain" \
--os-user-domain-name "oliverdomain" \
--os-password "<oadmin2_password>" server list

Substituting values for whatever project, domain, or user you are trying to authenticate as.

But a better way is to use [https://github.com/openstack/python-openstackclient]{.underline}. I set this up by first installing needed Python libraries:

sudo apt install python3-pip python3.10-venv -y

Then I setup my environment, sourced it, and installed python-openstack:

python3 -m venv openstack
source openstack/bin/activate
pip install python-openstackclient

Then I could source any .sh file! (below shows comparison after setting up a keypair for oadmin2!):

A screenshot of a computer Description automatically generated}

Sources: