Skip to content

Commit 41131a6

Browse files
authored
Merge pull request #20 from stackhpc/beokay-refactor
Create smslab/2023.1 branch
2 parents 1ded6ef + d01727f commit 41131a6

File tree

6 files changed

+225
-146
lines changed

6 files changed

+225
-146
lines changed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
Terraform for the following configuration:
44

5-
* OpenStack virtualised instances
5+
* OpenStack virtualised lab instances
6+
* An OpenStack virtualised container registry instance
67
* Cinder volumes for instance storage
78
* Floating IPs for networking
89

@@ -12,32 +13,34 @@ OpenStack infrastructure.
1213

1314
## Prerequisites
1415

15-
* A Neutron network the instances can attach to, with router
16+
* A Neutron network the instances can attach to, with a router
1617
* Plenty of resource quota
18+
* Terraform installed (see instructions
19+
[here](https://developer.hashicorp.com/terraform/install))
1720

1821
## Software Components
1922

20-
[Kayobe](https://docs.openstack.org/kayobe/latest/) enables deployment of
23+
[Kayobe](https://docs.openstack.org/kayobe/latest/) enables the deployment of
2124
containerised OpenStack to bare metal.
2225

2326
# Instructions for deployment
2427

25-
After cloning this repo, source the regular OpenStack rc file with necessary
26-
vars for accessing the *A Universe From Nothing* lab project.
28+
After cloning this repo, source the regular OpenStack rc file with the
29+
necessary vars for accessing the *A Universe From Nothing* lab project.
2730

28-
There are a various variables available for configuration. These can be seen
31+
There are various variables available for configuration. These can be seen
2932
in `vars.tf`, and can be set in `terraform.tfvars` (see sample file
3033
`terraform.tfvars.sample`).
3134

32-
Next up is the `terraform` bit assuming it is already installed:
35+
Create the resources using Terraform:
3336

3437
terraform init
3538
terraform plan
3639
terraform apply -auto-approve -parallelism=52
3740

3841
To reprovision a lab machine:
3942

40-
terraform taint openstack_compute_instance_v2.#
43+
terraform taint openstack_compute_instance_v2.lab[#]
4144
terraform apply -auto-approve
4245

4346
where `#` is the lab index which can be obtained from the web UI.
@@ -54,7 +57,7 @@ SSH in to your lab instance by running and entering the provided password:
5457

5558
ssh lab@<lab-ip-address> -o PreferredAuthentications=password
5659

57-
The default password is the id of the lab instance. As such, it is recommeded
60+
The default password is the id of the lab instance. As such, it is recommended
5861
that you run `passwd` immediately to change the default password.
5962

6063
## Nested virtualisation
@@ -75,7 +78,7 @@ When complete, it should report an elapsed time as follows:
7578

7679
[INFO] 22 minutes and 3 seconds elapsed.
7780

78-
## Inspect the bifrost container inside your seed VM:
81+
## Inspect the Bifrost container inside your seed VM:
7982

8083
8184
docker ps
@@ -85,7 +88,7 @@ When complete, it should report an elapsed time as follows:
8588

8689
Look at the steps involved in deploying Kayobe control plane:
8790

88-
< a-universe-from-seed.sh
91+
less a-universe-from-seed.sh
8992

9093
# Wrapping up
9194

a-seed-from-nothing.sh

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# Reset SECONDS
44
SECONDS=0
55

6-
# Cloud User: cloud-user (CentOS) or ubuntu?
7-
CLOUD_USER=cloud-user
8-
96
ENABLE_OVN=true
107

118
# Registry IP
@@ -14,19 +11,20 @@ registry_ip=$1
1411
echo "[INFO] Given docker registry IP: $registry_ip"
1512

1613
# Disable the firewall.
17-
if [[ "${CLOUD_USER}" = "ubuntu" ]]
18-
then
14+
if type apt; then
15+
grep -q $HOSTNAME /etc/hosts || (echo "$(ip r | grep -o '^default via.*src [0-9.]*' | awk '{print $NF}') $HOSTNAME" | sudo tee -a /etc/hosts)
1916
dpkg -l ufw && sudo systemctl is-enabled ufw && sudo systemctl stop ufw && sudo systemctl disable ufw
2017
else
2118
rpm -q firewalld && sudo systemctl is-enabled firewalld && sudo systemctl stop firewalld && sudo systemctl disable firewalld
22-
fi
2319

24-
# Disable SELinux.
25-
sudo setenforce 0
20+
# Disable SELinux.
21+
sudo setenforce 0
22+
fi
2623

2724
# Useful packages
28-
if [[ "${CLOUD_USER}" = "ubuntu" ]]
29-
then
25+
if type apt; then
26+
# Avoid the interactive dialog prompting for service restart: set policy to leave services unchanged
27+
echo "\$nrconf{restart} = 'l';" | sudo tee /etc/needrestart/conf.d/90-aufn.conf
3028
sudo apt update
3129
sudo apt install -y git tmux lvm2 iptables
3230
else
@@ -42,8 +40,7 @@ EOF
4240
sudo sysctl --load /etc/sysctl.d/70-ipv6.conf
4341

4442
# CentOS Stream 8 requires network-scripts. Rocky Linux 9 and onwards use NetworkManager.
45-
if [[ "${CLOUD_USER}" = "cloud-user" ]]
46-
then
43+
if type dnf; then
4744
case $(grep -o "[89]\.[0-9]" /etc/redhat-release) in
4845
"8.*")
4946
sudo dnf install -y network-scripts
@@ -60,6 +57,18 @@ then
6057
exit -1
6158
;;
6259
esac
60+
elif type apt; then
61+
# Prepare for disabling of Netplan and enabling of systemd-networkd.
62+
# Netplan has an interaction with systemd and cloud-init to populate
63+
# systemd-networkd files, but ephemerally. If /etc/systemd/network is
64+
# empty and netplan config files are present in /run, copy them over.
65+
persistent_netcfg=$(ls /etc/systemd/network)
66+
ephemeral_netcfg=$(ls /run/systemd/network)
67+
if [[ -z "$persistent_netcfg" && ! -z "$ephemeral_netcfg" ]]
68+
then
69+
echo "Creating persistent versions of Netplan ephemeral config"
70+
sudo cp /run/systemd/network/* /etc/systemd/network
71+
fi
6372
fi
6473

6574
# Exit on error
@@ -68,6 +77,7 @@ fi
6877
set -e
6978

7079
# Ensure an ssh key is generated
80+
CLOUD_USER=$(ls /home | grep -v lab | grep -v stack | head -1)
7181
# NOTE: you might think ~${CLOUD_USER} would work but apparently not
7282
CLOUD_USER_DIR=/home/${CLOUD_USER}
7383
keyfile="$HOME/.ssh/id_rsa"
@@ -86,43 +96,38 @@ then
8696
sudo chown ${CLOUD_USER}.${CLOUD_USER} ${CLOUD_USER_DIR}/.ssh/authorized_keys
8797
fi
8898

89-
# Clone Kayobe.
99+
# Clone Beokay.
90100
cd $HOME
91-
[[ -d kayobe ]] || git clone https://opendev.org/openstack/kayobe.git -b stable/yoga
92-
cd kayobe
101+
git clone https://github.com/stackhpc/beokay.git -b master
102+
103+
# Use Beokay to bootstrap your control host.
104+
[[ -d deployment ]] || beokay/beokay.py create --base-path ~/deployment --kayobe-repo https://opendev.org/openstack/kayobe.git --kayobe-branch stable/2023.1 --kayobe-config-repo https://github.com/stackhpc/a-universe-from-nothing.git --kayobe-config-branch stable/2023.1
93105

94106
# Bump the provisioning time - it can be lengthy on virtualised storage
95-
sed -i.bak 's%^[# ]*wait_active_timeout:.*% wait_active_timeout: 5000%' ~/kayobe/ansible/overcloud-provision.yml
107+
sed -i.bak 's%^[# ]*wait_active_timeout:.*% wait_active_timeout: 5000%' ~/deployment/src/kayobe/ansible/overcloud-provision.yml
96108

97109
# Clone the Tenks repository.
110+
cd ~/deployment/src/
98111
[[ -d tenks ]] || git clone https://opendev.org/openstack/tenks.git
99-
100-
# Clone this Kayobe configuration.
101-
mkdir -p config/src
102-
cd config/src/
103-
[[ -d kayobe-config ]] || git clone https://github.com/stackhpc/a-universe-from-nothing.git -b stable/yoga kayobe-config
112+
cd
104113

105114
# Set default registry name to the one we just created
106-
sed -i.bak 's/^docker_registry.*/docker_registry: '$registry_ip':4000/' kayobe-config/etc/kayobe/docker.yml
115+
sed -i.bak 's/^docker_registry:.*/docker_registry: '$registry_ip':4000/' ~/deployment/src/kayobe-config/etc/kayobe/docker.yml
107116

108117
# Configure host networking (bridge, routes & firewall)
109-
./kayobe-config/configure-local-networking.sh
110-
111-
# Install kayobe.
112-
cd ~/kayobe
113-
./dev/install-dev.sh
118+
~/deployment/src/kayobe-config/configure-local-networking.sh
114119

115120
# Enable OVN flags
116121
if $ENABLE_OVN
117122
then
118-
cat <<EOF | sudo tee -a config/src/kayobe-config/etc/kayobe/bifrost.yml
123+
cat <<EOF | sudo tee -a ~/deployment/src/kayobe-config/etc/kayobe/bifrost.yml
119124
kolla_bifrost_extra_kernel_options:
120125
- "console=ttyS0"
121126
EOF
122-
cat <<EOF | sudo tee -a config/src/kayobe-config/etc/kayobe/kolla.yml
127+
cat <<EOF | sudo tee -a ~/deployment/src/kayobe-config/etc/kayobe/kolla.yml
123128
kolla_enable_ovn: yes
124129
EOF
125-
cat <<EOF | sudo tee -a config/src/kayobe-config/etc/kayobe/neutron.yml
130+
cat <<EOF | sudo tee -a ~/deployment/src/kayobe-config/etc/kayobe/neutron.yml
126131
kolla_neutron_ml2_type_drivers:
127132
- geneve
128133
- vlan
@@ -134,17 +139,25 @@ kolla_neutron_ml2_tenant_network_types:
134139
EOF
135140
fi
136141

142+
# Set Environment variables for Kayobe dev scripts
143+
export KAYOBE_CONFIG_SOURCE_PATH=~/deployment/src/kayobe-config
144+
export KAYOBE_VENV_PATH=~/deployment/venvs/kayobe
145+
137146
# Deploy hypervisor services.
138-
./dev/seed-hypervisor-deploy.sh
147+
~/deployment/src/kayobe/dev/seed-hypervisor-deploy.sh
139148

140149
# Deploy a seed VM.
141150
# NOTE: This should work the first time because the packet configuration uses a
142151
# custom docker registry. However, there are sometimes issues with Docker starting up on the seed (FIXME)
143-
if ! ./dev/seed-deploy.sh; then
152+
if ! ~/deployment/src/kayobe/dev/seed-deploy.sh; then
144153
# Deploy a seed VM. Should work this time.
145-
./dev/seed-deploy.sh
154+
~/deployment/src/kayobe/dev/seed-deploy.sh
146155
fi
147156

157+
# Run TENKS
158+
export TENKS_CONFIG_PATH=~/deployment/src/kayobe-config/tenks.yml
159+
~/deployment/src/kayobe/dev/tenks-deploy-overcloud.sh ~/deployment/src/tenks
160+
148161
# Duration
149162
duration=$SECONDS
150163
echo "[INFO] $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."

a-universe-from-seed.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,10 @@ SECONDS=0
88

99
# FIXME: IP on public1 subnet disappears for braio interface during the course
1010
# of a-seed-from-nothing.sh script. Rerun the configuration script to re-add it.
11-
cd ~/kayobe/config/src/
12-
./kayobe-config/configure-local-networking.sh
13-
14-
# Change to kayobe directory
15-
cd ~/kayobe
16-
17-
# Create some 'bare metal' VMs for the controller and compute node.
18-
# NOTE: Make sure to use ./tenks, since just ‘tenks’ will install via PyPI.
19-
export TENKS_CONFIG_PATH=config/src/kayobe-config/tenks.yml
20-
./dev/tenks-deploy.sh ./tenks
11+
~/deployment/src/kayobe-config/configure-local-networking.sh
2112

2213
# Activate the Kayobe environment, to allow running commands directly.
23-
source dev/environment-setup.sh
14+
source ~/deployment/env-vars.sh
2415

2516
# Inspect and provision the overcloud hardware:
2617
kayobe overcloud inventory discover
@@ -32,7 +23,7 @@ kayobe overcloud provision
3223
kayobe overcloud host configure
3324
kayobe overcloud container image pull
3425
kayobe overcloud service deploy
35-
source config/src/kayobe-config/etc/kolla/public-openrc.sh
26+
source ~/deployment/src/kayobe-config/etc/kolla/public-openrc.sh
3627
kayobe overcloud post configure
3728

3829
# At this point it should be possible to access the Horizon GUI via the seed
@@ -49,12 +40,13 @@ kayobe overcloud host command run --command "iptables -P FORWARD ACCEPT" --becom
4940

5041
# The following script will register some resources in OpenStack to enable
5142
# booting up a tenant VM.
52-
source config/src/kayobe-config/etc/kolla/public-openrc.sh
53-
./config/src/kayobe-config/init-runonce.sh
43+
source ~/deployment/src/kayobe-config/etc/kolla/public-openrc.sh
44+
~/deployment/src/kayobe-config/init-runonce.sh
5445

5546
# Following the instructions displayed by the above script, boot a VM.
5647
# You'll need to have activated the ~/os-venv virtual environment.
57-
source ~/os-venv/bin/activate
48+
deactivate
49+
source ~/deployment/venvs/os-venv/bin/activate
5850
openstack server create --image cirros --flavor m1.tiny --key-name mykey --network demo-net demo1
5951

6052
# Assign a floating IP to the server to make it accessible.

openstack-device.tf

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "openstack_compute_keypair_v2" "ufn_lab_key" {
2-
name = "ufn_lab_key"
2+
name = "${var.lab_prefix}_lab_key"
33
public_key = tls_private_key.default.public_key_openssh
44
}
55

@@ -110,13 +110,75 @@ resource "null_resource" "registry" {
110110
}
111111
}
112112

113+
resource "openstack_compute_secgroup_v2" "AUFN" {
114+
name = "${var.lab_prefix}-lab-rules"
115+
description = "Access rules for AUFN lab deployment"
116+
117+
rule {
118+
from_port = 22
119+
to_port = 22
120+
ip_protocol = "tcp"
121+
cidr = "0.0.0.0/0"
122+
}
123+
124+
rule {
125+
from_port = 80
126+
to_port = 80
127+
ip_protocol = "tcp"
128+
cidr = "0.0.0.0/0"
129+
}
130+
131+
rule {
132+
from_port = 3000
133+
to_port = 3000
134+
ip_protocol = "tcp"
135+
cidr = "0.0.0.0/0"
136+
}
137+
138+
rule {
139+
from_port = 5601
140+
to_port = 5601
141+
ip_protocol = "tcp"
142+
cidr = "0.0.0.0/0"
143+
}
144+
145+
rule {
146+
from_port = 9091
147+
to_port = 9091
148+
ip_protocol = "tcp"
149+
cidr = "0.0.0.0/0"
150+
}
151+
152+
rule {
153+
from_port = 9093
154+
to_port = 9093
155+
ip_protocol = "tcp"
156+
cidr = "0.0.0.0/0"
157+
}
158+
}
159+
160+
data "openstack_dns_zone_v2" "lab_zone" {
161+
count = var.dns_zone_name != null ? 1 : 0
162+
name = var.dns_zone_name
163+
}
164+
165+
resource "openstack_dns_recordset_v2" "lab_dns" {
166+
count = var.dns_zone_name != null ? var.lab_count : 0
167+
zone_id = data.openstack_dns_zone_v2.lab_zone[0].id
168+
name = format("%s-lab-%02d.%s", var.lab_prefix, count.index, var.dns_zone_name)
169+
type = "A"
170+
ttl = 300
171+
records = [openstack_compute_instance_v2.lab[count.index].network[0].fixed_ip_v4]
172+
}
173+
113174
resource "openstack_compute_instance_v2" "lab" {
114175

115176
count = var.lab_count
116177
name = format("%s-lab-%02d", var.lab_prefix, count.index)
117178
image_name = var.image_name
118179
flavor_name = var.lab_flavor
119180
key_pair = openstack_compute_keypair_v2.ufn_lab_key.name
181+
security_groups = ["default", openstack_compute_secgroup_v2.AUFN.name ]
120182

121183
dynamic "block_device" {
122184
for_each = var.boot_labs_from_volume ? [1] : []

0 commit comments

Comments
 (0)