Skip to content

Commit

Permalink
Merge pull request #38 from stfc/Amphora_image_tweaks
Browse files Browse the repository at this point in the history
Amphora image tweaks
  • Loading branch information
gmatthews20 authored Nov 29, 2024
2 parents 872e47b + ea9462b commit f808ebf
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 12 deletions.
26 changes: 25 additions & 1 deletion .github/workflows/amphora_builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Exec Amphora build
run: cd amphora-image-builder && ./build.sh
run: |
cd $GITHUB_WORKSPACE/amphora-image-builder
./build.sh
sudo chown -R $USER:$USER $GITHUB_WORKSPACE/output
- name: Check image is valid
run: |
cd $GITHUB_WORKSPACE
sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-utils
qemu-img check output/amphora-x64-$(date +%Y-%m-%d)-haproxy.qcow2
- name: SHA256 image
run: |
cd $GITHUB_WORKSPACE
sha256sum output/amphora-x64-$(date +%Y-%m-%d)-haproxy.qcow2 > output/amphora-x64-$(date +%Y-%m-%d)-haproxy.qcow2.sha256
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: amphora-image
if-no-files-found: error
path: output/*qcow2*
compression-level: 0 # qcow2 files are already compressed
retention-days: 7
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Amphora output files
amphora-x64*.raw
amphora-x64*.d/
log.txt

# Byte-compiled / optimized / DLL files
__pycache__/
Expand All @@ -22,6 +23,7 @@ lib/
lib64/
parts/
sdist/
output/
var/
wheels/
share/python-wheels/
Expand Down
3 changes: 1 addition & 2 deletions amphora-image-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand All @@ -10,7 +10,6 @@ RUN apt-get update && \
# rather than main
COPY ./ /opt/cloud-image-builders


COPY amphora-image-builder/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

Expand Down
23 changes: 22 additions & 1 deletion amphora-image-builder/README
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,26 @@ Usage
# Set as appropriate to your environment
export TARGET_PROJECT=service

openstack image create --property hw_disk_bus=virtio --property hw_scsi_model=virtio-scsi --property hw_vif_multiqueue_enabled=true --private --project $TARGET_PROJECT --disk-format qcow2 --container-format bare --file amphora-x64-haproxy.qcow2 --progress amphora-x64-$(date +%Y-%m-%d)-haproxy
openstack image create --property hw_disk_bus=virtio --property hw_scsi_model=virtio-scsi --property hw_vif_multiqueue_enabled=true --private --project $TARGET_PROJECT --disk-format qcow2 --container-format bare --file ../output/amphora-x64-$(date +%Y-%m-%d)-haproxy.qcow2 --progress amphora-x64-$(date +%Y-%m-%d)-haproxy
```

Enabling this for the Amphora
-----------------------------

- Share this image with the admin project so the control plane can see it after it's tagged

```
openstack image set --shared --project admin amphora-x64-$(date +%Y-%m-%d)-haproxy
openstack image add project amphora-x64-$(date +%Y-%m-%d)-haproxy admin
openstack image set --accept --project admin amphora-x64-$(date +%Y-%m-%d)-haproxy
```

- Tag this image with the Amphora image tag
```
openstack image set --tag amphora amphora-x64-$(date +%Y-%m-%d)-haproxy
```

- Untag the old image after testing
```
openstack image unset --tag amphora amphora-<old-date>
```
2 changes: 1 addition & 1 deletion amphora-image-builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ docker build -f amphora-image-builder/Dockerfile -t amphora-image-builder:local

# The Amphora builder requires privileged access to the host
# to mount /proc and /sys
docker run --privileged -v "$(pwd)":/output amphora-image-builder:local
docker run --privileged -v "$(pwd)/output":/output amphora-image-builder:local
cd amphora-image-builder
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ apt-get install python3-pip python3-venv -y
/usr/bin/python3 -m venv /tmp/amphora-venv
source /tmp/amphora-venv/bin/activate
/usr/bin/python3 -m pip install ansible
/usr/bin/git clone https://github.com/stfc/cloud-image-builders.git
/usr/bin/git clone https://github.com/stfc/cloud-image-builders.git --depth=1
cd cloud-image-builders

apt-get install language-pack-en -y
locale-gen en_GB.UTF-8
dpkg-reconfigure --frontend noninteractive locales
update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8
apt-get install locale -y && apt-get clean all
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
locale-gen en_US.UTF-8
source /etc/default/locale
locale

apt-get install gpg-agent -y
/usr/bin/gpg-agent --daemon
Expand All @@ -26,3 +25,5 @@ sed -i "s/hosts: default/hosts: localhost/g" os_builders/*.yml
mkdir -p /var/ossec/etc/extra
echo "{\"groups\": [\"default\", \"cloud\", \"ubuntu\", \"debian\", \"octavia-amphora\"], \"labels\": {\"amphora-build-date\": \"$(date '+%Y-%m-%d %H:%M:%S')\" }}" > /var/ossec/etc/extra/03-amphora.json
ansible-playbook os_builders/prepare_user_image.yml --extra-vars provision_this_machine=true -i os_builders/inventory/localhost.yml

apt-get autoremove -y
5 changes: 4 additions & 1 deletion amphora-image-builder/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

set -euxo pipefail

DIB_RELEASE="jammy" # Ubuntu 22.04
export DIB_RELEASE

cd /tmp
python3 -m virtualenv octavia_disk_image_create
# shellcheck source=/dev/null
source octavia_disk_image_create/bin/activate

git clone --depth=1 https://github.com/openstack/octavia
git clone --depth=1 https://opendev.org/openstack/octavia
DIB_REPO_PATH="$(pwd)/octavia"
export DIB_REPO_PATH

Expand Down

0 comments on commit f808ebf

Please sign in to comment.