Streamline naming and fix qcow-bundle tag naming

Fix an issue with qcow-bundle naming that was causing docker registry
info to be dropped.

Dropped redundant "qcow" prefix for qcow-bundle subdirectories.

Use qcow-bundle subdirectory as image name.

Rename "config" directory as "manifests" per offline review request.

Change-Id: Ie110923b3c8d5a825dd7a199658722b853018d97
This commit is contained in:
Anderson, Craig (ca846m) 2021-03-19 11:31:28 -07:00
parent a9b4c59f6b
commit 9066690daf
24 changed files with 24 additions and 30 deletions

View File

@ -22,7 +22,7 @@ IMAGE_TAG ?= latest
IMAGE_TYPE ?= iso # iso | qcow
PUSH_IMAGE ?= false
DISTRO ?= ubuntu_focal
WORKDIR ?= ./config
WORKDIR ?= ./manifests
QCOW_BUNDLE ?= ${WORKDIR}/qcow-bundle
# Specify if you want to only build a certain subset of QCOW bundles
QCOW_BUNDLE_DIRS ?=
@ -114,15 +114,11 @@ else
# Assemble all images based on configs defined in each subdirectory
iterDirs=`find $(QCOW_BUNDLE) -maxdepth 1 -mindepth 1 -type d -exec basename {} \;`
for subdir in $$iterDirs; do
# ISO configs
export user_data=$(QCOW_BUNDLE)/$$subdir/user_data
export network_config=$(QCOW_BUNDLE)/$$subdir/network_data.json
# QCOW configs
qcow_type=$$(echo $$subdir | sed -e "s/^qcow-//")
export osconfig_params="$(QCOW_BUNDLE)/$$subdir/osconfig-$$qcow_type-vars.yaml"
export qcow_params="$(QCOW_BUNDLE)/$$subdir/qcow-$$qcow_type-vars.yaml"
# Shared configs
export img_name=$$(cat $(QCOW_BUNDLE)/$$subdir/img_name)
export osconfig_params="$(QCOW_BUNDLE)/$$subdir/osconfig-vars.yaml"
export qcow_params="$(QCOW_BUNDLE)/$$subdir/qcow-vars.yaml"
# Image name
export img_name=$$subdir.qcow2
sudo -E tools/cut_image.sh $(IMAGE_TYPE) $(QCOW_BUNDLE) $(IMAGE) "$(PROXY)" "$(NO_PROXY)"
done
endif
@ -144,7 +140,7 @@ endif
for bundledir in $$bundleDirs; do
export QCOW_BUNDLE="$(WORKDIR)/$$bundledir"
sudo -E make cut_image
sudo -E DOCKER_BUILDKIT=1 docker -D -l debug build --tag $$bundledir -f Dockerfile-qcow.$(DISTRO) $(WORKDIR)/$$bundledir \
sudo -E DOCKER_BUILDKIT=1 docker -D -l debug build --tag $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$$bundledir:$(IMAGE_TAG)-$(DISTRO) -f Dockerfile-qcow.$(DISTRO) $(WORKDIR)/$$bundledir \
--label $(LABEL) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=\

1
image-builder/config Symbolic link
View File

@ -0,0 +1 @@
manifests/

View File

@ -1 +0,0 @@
control-plane.qcow2

View File

@ -1 +0,0 @@
data-plane.qcow2

View File

@ -1 +0,0 @@
../qcow-control-plane/qcow-control-plane-vars.yaml

View File

@ -1,29 +1,29 @@
Directory structure:
|-- config
```
|-- manifests
|-- iso
+-- network_data.json
+-- user_data
|-- qcow-bundle
|-- qcow-control-plane
+-- img_name
+-- osconfig-control-plane-vars.yaml
+-- qcow-control-plane-vars.yaml
|-- qcow-data-plane
+-- img_name
+-- osconfig-control-plane-vars.yaml
+-- qcow-control-plane-vars.yaml
|-- control-plane
+-- osconfig-vars.yaml
+-- qcow-vars.yaml
|-- data-plane
+-- osconfig-vars.yaml
+-- qcow-vars.yaml
```
The `generate_iso` and `package_qcow` make target can be used to build ISO and
QCOW artifacts respectively, after the shared `image-builder` container is
built (built with the `build` target).
The ISO always builds out of the `config/iso` directory, because this is only
The ISO always builds out of the `manifests/iso` directory, because this is only
used for local testing. It is not an artifact that is promoted or published.
QCOWs are grouped into publishable "bundles", i.e. a container image where all
QCOWs needed for a given deployment are stored. A bundle will be built for each
`config/qcow-bundle*` directory. Each `config/qcow-bundle*` directory contains
`manifests/qcow-bundle*` directory. Each `manifests/qcow-bundle*` directory contains
one subdirectory per QCOW that is part of that bundle, where overrides for
those images can be placed.
@ -32,6 +32,5 @@ The following items are expected in the `iso` directory:
- `network_data.json` - JSON file containing cloud-init network data
QCOWs expect the following files to be present in their directory:
- `img_name` - text file containing the desired name for the image
- `osconfig-*-vars.yaml` - YAML file containing `osconfig` playbook overrides
- `qcow-*-vars.yaml` - YAML file containing `qcow` playboook overrides
- `osconfig-vars.yaml` - YAML file containing `osconfig` playbook overrides
- `qcow-vars.yaml` - YAML file containing `qcow` playboook overrides

View File

@ -0,0 +1 @@
../control-plane/qcow-vars.yaml

View File

@ -12,7 +12,7 @@ BASEDIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
# Whether to build an 'iso' or 'qcow'
build_type="${1:-qcow}"
# The host mount to use to exchange data with this container
host_mount_directory="${2:-$BASEDIR/../config}"
host_mount_directory="${2:-$BASEDIR/../manifests}"
# Docker image to use when launching this container
image="${3:-port/image-builder:latest-ubuntu_focal}"
# proxy to use, if applicable
@ -89,7 +89,7 @@ outputFileName: $img_name" > ${iso_config}
disk1="--disk path=${workdir}/${img_name},device=cdrom"
network='--network network=default,mac=52:54:00:6c:99:85'
elif [[ $build_type == qcow ]]; then
: ${img_name:=$(cat $(dirname ${osconfig_params})/img_name)}
: ${img_name:=airship-ubuntu.qcow}
if sudo virsh list | grep ${img_name}; then
sudo virsh destroy ${img_name}
fi

View File

@ -12,7 +12,7 @@ BASEDIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
build_dir=assets/playbooks/build
osconfig_build_dir=$(basename $build_dir)
host_mount_directory="${1:-$BASEDIR/../config}"
host_mount_directory="${1:-$BASEDIR/../manifests}"
workdir="$(realpath ${host_mount_directory})"
install_pkg(){