> For the complete documentation index, see [llms.txt](https://paul-gleason.gitbook.io/champlain-college-classes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paul-gleason.gitbook.io/champlain-college-classes/labs/milestone-9-openstack-tutorials.md).

# Milestone 9 - OpenStack Tutorials

## Services Commands:

Display services:

```
microstack.openstack catalog list
```

Display users:

```
microstack.openstack user list
```

Display images:

```
microstack.openstack image list
```

Display networks:

```
microstack.openstack network list
```

Display hypervisors:

```
microstack.openstack hypervisor list
```

## Dashboard Navigation:

#### Themes:

<figure><img src="/files/SZqx3pIJQcr2Mb6cyHz4" alt=""><figcaption></figcaption></figure>

#### Users:

Access users:

<figure><img src="/files/myE4hn7H7ITIuQAZmuVX" alt=""><figcaption></figcaption></figure>

Change user password:

<figure><img src="/files/zlCQB1E6FHOqokLTdarz" alt=""><figcaption></figcaption></figure>

#### Project Menu:

Project drop down:

<figure><img src="/files/SyhLBFNCTktBtLjbJcvj" alt=""><figcaption></figcaption></figure>

The **Project** menu on the left is grouped into three sections:

* **API Access** provides information about API endpoints of OpenStack services.
* **Compute** provides access to project compute resources, such as instances.
* **Network** provides access to project network resources, such as virtual networks.

List images for a project:

<figure><img src="/files/nt0Z5PsdN6AcGT0GVQhE" alt=""><figcaption></figcaption></figure>

#### Admin Menu:

The **Admin** menu on the left is grouped into five sections:

* **Overview** displays usage metrics across all projects.
* **Compute** provides access to global compute resources, such as hypervisors.
* **Network** provides access to global network resources, such as RBAC policies.
* **System** provides access to various system information.
* **Optimization** currently not used

<figure><img src="/files/tWuPcBsNGYHGKY349aJa" alt=""><figcaption></figcaption></figure>

#### Identity Menu:

The **Identity** menu on the left is grouped into six sections:

* **Domains** provides acces to domains.
* **Projects** provides access to project accounts.
* **Users** provides access to user accounts.
* **Groups** provides access to user groups.
* **Roles** provides access to user roles.
* **Application Credentials** provides access to application credentials.

<figure><img src="/files/ChrzYIhfcEYxeTbuxrDJ" alt=""><figcaption></figcaption></figure>

## Templates:

Create Image:

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

<figure><img src="/files/8KJ25KTWNRr1ja1FOIk7" alt=""><figcaption></figcaption></figure>

List images:

```
microstack.openstack image list
```

<figure><img src="/files/QGQtWhZoad5INbiYIKrM" alt=""><figcaption></figcaption></figure>

Manage through dashboard:

<figure><img src="/files/5chD93dWzmbiIXk5hGnb" alt=""><figcaption></figcaption></figure>

Example upload:

* **Image Name** - Type `ubuntu-focal`
* **File** - Click **Browse** and find the **focal-server-cloudimg-amd64-disk-kvm.img** file in your **Downloads** directory
* **Format** - Select **QCOW2 - QEMU Emulator**
* **Minimum Disk (GB)** - Type `8`
* **Minimum RAM (MB)** - Type `512`
* **Visibility** - Choose **Private**

#### Manage flavors:

Create a flavor:

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

<figure><img src="/files/uxytgDxYFYFvAnf6L1us" alt=""><figcaption></figcaption></figure>

List flavors:

```
microstack.openstack flavor list
```

<figure><img src="/files/ypZVWhU2krtraINnNPJq" alt=""><figcaption></figcaption></figure>

Manage flavors in dashboard:

<figure><img src="/files/fiFnlo42Z1ZJuj8V5S1L" alt=""><figcaption></figcaption></figure>

To create the flavor, fill in the form as follows:

* **Name** - Type `paul-flavor`
* **VCPUS** - Type `1`
* **RAM (MB)** - Type `1024`
* **Root Disk (GB)** - Type `10`

## Identities:

#### Manage Domains:

Create domain:

```
microstack.openstack domain create --description "paul_domain" pauldomain
```

<figure><img src="/files/3wkf1JUNiPVewUgG8SfI" alt=""><figcaption></figcaption></figure>

List domain:

```
microstack.openstack domain list
```

<figure><img src="/files/WyYgVACXtIvxgnZ6bhB4" alt=""><figcaption></figcaption></figure>

Create domain user:

```
microstack.openstack user create --domain pauldomain --password <password> admin
microstack.openstack role add --domain pauldomain --user-domain pauldomain --user admin admin
```

Oliver added the following code to enable domains:

add 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`:

![](https://github.com/Oliver-Mustoe/Oliver-Mustoe-Tech-Journal/raw/main/tech_journal_backups/SYS-350/sys350-m9/media/image26.png)

Then ran:

```
sudo snap restart microstack.horizon-uwsgi
```

To login with domain user:

<figure><img src="/files/5BEIVjvw4wTBMdYJ3BlA" alt=""><figcaption></figcaption></figure>

Domains:

<figure><img src="/files/2EH0tuCqceGEGp6SQLmW" alt=""><figcaption></figcaption></figure>

#### Manage Roles:

Create role:

```
microstack.openstack role create _paulmember_
```

List roles:

```
microstack.openstack role list
```

<figure><img src="/files/YTCpSQXYSFWJQnlKmcpN" alt=""><figcaption></figcaption></figure>

#### Project management:

Create project:

```
microstack.openstack project create --domain pauldomain paulproject
```

List project in domain:

```
microstack.openstack project list --domain pauldomain
```

<figure><img src="/files/cDCkPro1vWajb3W78EuW" alt=""><figcaption></figcaption></figure>

#### User and group management:

Create new user:

```
microstack.openstack user create --domain pauldomain --password <password> admin2
```

Create a new group:

```
microstack.openstack group create --domain pauldomain paulgroup
```

List groups:

```
microstack.openstack group list --domain pauldomain
```

<figure><img src="/files/LX97IBDpC54SKAGPyqHc" alt=""><figcaption></figcaption></figure>

#### Membership and assignment management:

Add user to group:

```
microstack.openstack group add user --group-domain pauldomain --user-domain pauldomain paulgroup admin2
```

Assign group to project:

```
microstack.openstack role add --project paulproject --project-domain pauldomain --group paulgroup --group-domain pauldomain member
```

## Multi-tenancy:

#### Setup:

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


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

source ~/Downloads/pauldomain_admin2.sh
```

#### Keypair:

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

## Networking:

#### Network:

Create network:

```
microstack.openstack network create paulnetwork
```

List networks:

```
microstack.openstack network list
```

<figure><img src="/files/cN7kDSRV2IHsiwwyIfP6" alt=""><figcaption></figcaption></figure>

#### Subnet:

Create subnet:

```
microstack.openstack subnet create --network paulnetwork --subnet-range 10.5.0.0/24 --allocation-pool start=10.5.0.75,end=10.5.0.100 --dns-nameserver 1.1.1.1 paulsubnet
```

List subnets:

```
microstack.openstack subnet list
```

<figure><img src="/files/DMz6KQK1Wu1gIFBgBPpO" alt=""><figcaption></figcaption></figure>

#### Routers:

Create:

<pre><code><strong>microstack.openstack router create paulrouter
</strong></code></pre>

List:

```
microstack.openstack router list
```

<figure><img src="/files/4dx1cVkM0go8oA6wMmKc" alt=""><figcaption></figcaption></figure>

Set external network:

```
microstack.openstack router set --external-gateway external-network paulrouter
```

Add subnet:

```
microstack.openstack router add subnet paulrouter paulsubnet
```

#### Floating IPs:

Create:

```
microstack.openstack floating ip create external
```

list:

```
microstack.openstack floating ip list
```

#### Security Groups:

Create:

<pre><code><strong>microstack.openstack security group create paulsecuritygroup
</strong></code></pre>

list:

```
microstack.openstack security group list
```

<figure><img src="/files/Jl2RibsNuVFDdlkhBVPd" alt=""><figcaption></figcaption></figure>

All 22 to my security group:

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

List rules:

```
microstack.openstack security group rule list paulsecuritygroup
```

<figure><img src="/files/NdtF0kACvt9HIKLeu75o" alt=""><figcaption></figcaption></figure>

## Instances:

#### Launch instance:

launch:

```
microstack.openstack --insecure server create --flavor paul-flavor --image cirros --network paulnetwork --key-name mykeypair --min 2 --max 2 paulinstance
```

Server list:

```
microstack.openstack server list
```

#### Floating IP to instance:

<pre><code>IP=$(openstack --insecure floating ip list | tail -n 2 | head -n 1 | awk '{print $4}')
<strong>microstack.openstack --insecure server add floating ip paulinstance $IP
</strong></code></pre>

#### Attach security to instance:

```
microstack.openstack server add security group paulinstance paulsecuritygroup
```

#### Attach security group:

```
chmod 0400 ~/Downloads/mykeypair.pem
```

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

#### Delete Instance:

```
microstack.openstack server delete paulinstance
```
