Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions cluster-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Setup
- Install Ansible, if the version of Ansible core is too old it can be upgraded with:

```shell
sudo apt-get install python3.9-venv unzip -y
python3.9 -m venv venv
sudo apt-get install python3-venv unzip -y
python3 -m venv venv
source venv/bin/activate
pip install "ansible" "ansible-core" --upgrade
pip install -r os_builders/requirements.txt
```

- cd to the `os_builders` directory
Expand All @@ -22,17 +22,10 @@ pip install "ansible" "ansible-core" --upgrade
cd os_builders

# If sudo is passwordless:
ansible-playbook -i inventory/localhost.yml playbooks/prep_builder.yml
ansible-playbook prep_builder.yml

# If password is required for sudo:
ansible-playbook -i inventory/localhost.yml playbooks/prep_builder.yml --ask-become-pass
```
- Log out and back in again to ensure the groups are applied
```shell
groups | grep -i kvm # no output
exit
# ssh <user>@<host>
groups | grep -i kvm # output: kvm
ansible-playbook prep_builder.yml --ask-become-pass
```

Rate Limiting
Expand All @@ -44,6 +37,11 @@ You may run into GitHub rate limiting issues when building images. To avoid this

The token can be generated from your GitHub settings, under developer access, and only needs the `public_repo` scope (i.e. the default).

OpenStack authentication
------------------------

You needm to set up credentials for OpenStack authentication as we are using a remote builder. You can either put your clouds.yaml application credential into `~/.config/openstack/clouds.yaml` or use a `.openrc` to set up the environment variables.

Building the latest image
=========================

Expand All @@ -55,10 +53,10 @@ git submodule update --init --recursive --remote

# Point to our custom roles:
export ANSIBLE_ROLES_PATH="$(pwd)/os_builders/roles:$(pwd)/cluster-api/roles"
export PACKER_VAR_FILES="$(pwd)/cluster-api/ansible_stfc_roles.json"
export PACKER_VAR_FILES="$(pwd)/cluster-api/<environment>_vars.json"

# Run build
make -C k8s-image-builder/images/capi build-qemu-ubuntu-2204
make -C k8s-image-builder/images/capi build-openstack-ubuntu-2204
```

Building a custom version
Expand All @@ -71,11 +69,11 @@ To build a custom version of the image, you can specify the version of the image
cd .. # back to repo root
export ANSIBLE_ROLES_PATH="$(pwd)/os_builders/roles:$(pwd)/cluster-api/roles"
export K8S_VERSION="cluster-api/versions/v1_25.json"
export ROLE_DEFINITION="cluster-api/ansible_stfc_roles.json"
export ROLE_DEFINITION="cluster-api/<environment>_vars.json"

export PACKER_VAR_FILES="$(pwd)/${K8S_VERSION} $(pwd)/${ROLE_DEFINITION}"

make -C k8s-image-builder/images/capi build-qemu-ubuntu-2204
make -C k8s-image-builder/images/capi build-openstack-ubuntu-2204
```

Adding a new version
Expand Down
4 changes: 0 additions & 4 deletions cluster-api/ansible_stfc_roles.json

This file was deleted.

14 changes: 14 additions & 0 deletions cluster-api/dev_vars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extra_debs": "nfs-common open-iscsi",
"node_custom_roles_post": "vm_baseline containerd",
"volume_type": "f7afc62e-999d-4812-9bf3-7f4f93680bad",
"_volume_type_comment": "UUID of volume type cinder # openstack volume type list",
"source_image": "",
"source_image_filter_name": "ubuntu-jammy-22.04-nogui",
"flavor": "l3.nano",
"volume_size": "50",
"networks": "fa2f5ebe-d0e0-4465-9637-e9461de443f1",
"use_blockstorage_volume": "false",
"image_disk_format": "",
"floating_ip_network": ""
}
14 changes: 14 additions & 0 deletions cluster-api/prod_vars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extra_debs": "nfs-common open-iscsi",
"node_custom_roles_post": "vm_baseline containerd",
"volume_type": "446c92c3-9f5e-43eb-8afd-10726a1b3f9c",
"_volume_type_comment": "UUID of volume type cinder # openstack volume type list",
"source_image": "",
"source_image_filter_name": "ubuntu-jammy-22.04-nogui",
"flavor": "l3.nano",
"volume_size": "50",
"networks": "5be315b7-7ebd-4254-97fe-18c1df501538",
"use_blockstorage_volume": "false",
"image_disk_format": "",
"floating_ip_network": ""
}
7 changes: 5 additions & 2 deletions scripts/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
set -euxo pipefail
shift $((OPTIND-1))

# Enter dev or prod when running this script. I.e ./build-all.sh dev
env=$1
# Get root of repo based on the location of this script
REPO_ROOT="$(dirname "$(dirname "$(readlink -fm "$0")")")"

# Store the location to the custom roles which are shared from our OS builder...
CUSTOM_ROLE_PATH="${REPO_ROOT}/cluster-api/ansible_stfc_roles.json"

CUSTOM_ROLE_PATH="${REPO_ROOT}/cluster-api/${env}_vars.json"
# ... and make sure Ansible knows where to find on this machine
export ANSIBLE_ROLES_PATH="${REPO_ROOT}/os_builders/roles:${REPO_ROOT}/cluster-api/roles"

Expand All @@ -17,5 +20,5 @@ VERSIONS=( "${REPO_ROOT}"/cluster-api/versions/*.json )
for version_path in "${VERSIONS[@]}"; do
echo "Building image for version: ${version_path}..." && \
export PACKER_VAR_FILES="${CUSTOM_ROLE_PATH} ${version_path}" && \
make -C "${REPO_ROOT}/k8s-image-builder/images/capi" build-qemu-ubuntu-2204 &
make -C "${REPO_ROOT}/k8s-image-builder/images/capi" build-openstack-ubuntu-2204 &
done