# From Ubuntu iso to openstack (All-In-One)

# Ubuntu installation

## Keyboard configuration

Use your favorite keyboard layout

Here: fr/fr

## Choose type of install

Select `Ubuntu Server (minimized)` without checking “Search for third-party drivers”

## Network configuration

ens18 can be dhcp or manual

ens19 must be disabled for now

## Configure proxy

If you have a proxy to use, configure it, but here nope

## Configure Ubuntu archive mirror

If you have a mirror @ home or cache, you can use it. Here we’ll use default mirror

## Guided storage configuration

Do as you want, here I use default configuration without encryption

## Storage configuration

ubuntu-lv must be resized to maximum size.

## Profile setup

Do as you want

## Upgrade to Ubuntu Pro

Do as you want, here I skip for now

## SSH Setup

Install OpenSSH Server

You can import your ssh keys from GitHub or Launchpad.

## Featured Server Snaps

DO NOT CHECK ANYTHING

## Install complete

Wait for system update before reboot

After that, you can reboot and remove your bootable media.

# Configure lvm partition

## Fdisk

```bash
sudo fdisk /dev/<disk>
```


 1. n
 2. p
 3. ENTER
 4. ENTER
 5. t
 6. L
 7. Look at 8e, it must be LVM (if not, search for “Linux LVM”)
 8. Type 8e or new code
 9. p
10. Look if it’s marked as “Linux LVM”
11. w

## Create cinder-volumes


1. sudo pvcreate -f /dev/<disk>1
2. sudo vgcreate -f cinder-volumes /dev/<disk>1
3. Verify if all is ok with: sudo vgs

# User rights

As default user, when you need privilege escalation, you need to type a password.

Ansible cannot know the password without telling him OR by modifying sudoers file.

```bash
sudo visudo
```

Put this:

```yaml
leo ALL=(ALL:ALL) NOPASSWD:ALL
```

# Networking

In `/etc/netplan/00-installer-config.yaml`:

```bash
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens18:
      dhcp4: true
    ens19:
      dhcp4: false
      dhcp6: false
  version: 2
```


# Install Kolla-Ansible

## Install dependencies

```bash
sudo apt update && sudo apt install ufw python3-dev git libffi-dev gcc libssl-dev && sudo apt install python3-pip && sudo pip3 install -U pip
```

## Install Kolla-Ansible

```bash
sudo pip3 install git+https://opendev.org/openstack/kolla-ansible@master && sudo mkdir -p /etc/kolla && sudo chown $USER:$USER /etc/kolla && cp -r /usr/local/share/kolla-ansible/etc_examples/kolla/* /etc/kolla && cp /usr/local/share/kolla-ansible/ansible/inventory/* .
```


## Install Ansible dependencies

```bash
kolla-ansible install-deps
```

## Prepare installation

### Generate passwords

```bash
kolla-genpwd
```

### Edit configuration (/etc/kolla/globals.yml)

```yaml
kolla_base_distro: "ubuntu"
openstack_release: "zed"
network_interface: "ens18"
neutron_external_interface: "ens19"
kolla_internal_vip_address: "10.1.2.250"
openstack_region_name: "eu-west" # Can be anything in one word
enable_openstack_core: "yes"
enable_heat: "yes"
enable_cinder: "yes"
enable_cinder_backend_lvm: "yes"
cinder_volume_group: "cinder-volumes"
neutron_plugin_agent: "openvswitch"
enable_neutron_provider_networks: "yes"
enable_neutron_qos: "yes"
nova_compute_virt_type: "kvm"
```

## Deployment

```bash
kolla-ansible -i ./all-in-one bootstrap-servers && kolla-ansible -i ./all-in-one prechecks && kolla-ansible -i ./all-in-one deploy
```


## Setup openstack cli


```bash
sudo pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/master
```


```bash
kolla-ansible post-deploy && sudo cp /etc/kolla/clouds.yaml /etc/openstack && mkdir ~/.config && sudo cp /etc/kolla/clouds.yaml ~/ && sudo chown $USER:$USER clouds.yaml
```

## Create “default” flavor

```bash
openstack --os-cloud kolla-admin flavor create --vcpus 1 --ram 512 --disk 1 m1.tiny && \
    openstack --os-cloud kolla-admin flavor create --vcpus 1 --ram 2048 --disk 20 m1.small && \
    openstack --os-cloud kolla-admin flavor create --vcpus 2 --ram 4096 --disk 40 m1.medium && \
    openstack --os-cloud kolla-admin flavor create --vcpus 4 --ram 8192 --disk 80 m1.large && \
    openstack --os-cloud kolla-admin flavor create --vcpus 8 --ram 16384 --disk 160 m1.xlarge
```

## Reboot


:::info
Reboot after installation is better but not mandatory

:::

## Setup Network

### Create basic public router

```bash
openstack --os-cloud kolla-admin router create router && \
openstack --os-cloud kolla-admin network create local-net && \
openstack --os-cloud kolla-admin subnet create --subnet-range 10.0.0.0/16 --network local-net --gateway 10.0.0.1 --dns-nameserver 8.8.8.8 local-subnet && \
openstack --os-cloud kolla-admin router add subnet router local-subnet && \
openstack --os-cloud kolla-admin network create --external --provider-physical-network physnet1 --provider-network-type flat public1 && \
openstack --os-cloud kolla-admin subnet create --allocation-pool start=10.1.2.150,end=10.1.2.199 --network public1 --subnet-range 10.1.2.0/24 --gateway 10.1.2.1 public1-subnet && \
openstack --os-cloud kolla-admin router set --external-gateway public1 router
```

### Enable packet forwarding

#### Edit `/etc/sysctl.conf` 

```bash
net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
```

#### iptables command

```bash
sudo iptables -t nat -A POSTROUTING -o ens18 -j MASQUERADE
```


:::warning
If you did not reboot your server, please enable the ens19 interface

```bash
sudo ip link set dev ens19 up
```

:::

# Testing installation

## Import Cirros image

```bash
wget https://download.cirros-cloud.net/0.6.0/cirros-0.6.0-x86_64-disk.img
openstack --os-cloud kolla-admin image create --container-format bare \
--disk-format qcow2 --file cirros-0.6.0-x86_64-disk.img cirros
```

## Import Ubuntu 22.04 image

```bash
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
openstack --os-cloud kolla-admin image create --container-format bare \
--disk-format qcow2 --file jammy-server-cloudimg-amd64.img ubuntu-22.04
```

## Create security groupe allowing ssh

```bash
openstack --os-cloud kolla-admin security group create ssh && \
openstack --os-cloud kolla-admin security group rule create --protocol tcp --remote-ip 0.0.0.0/0 --ingress --dst-port 22 ssh
```

---

**Documents**

- [AS205126](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/as205126-UD37o91h51)
- [Kubernetes](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/kubernetes-AYsNjQV7SW)
- [Proxmox](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/proxmox-TnNEgoRFwj)
- [DN42](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/dn42-oTEE68Qn7n)
- [Openshift](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/openshift-428FG3kMtg)
- [Openstack](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/openstack-KJmz0J0klm)