Skip to content

Commit ebe7a53

Browse files
committed
Add GCP images for AlmaLinux 8, 9, and 10
1 parent 31282b2 commit ebe7a53

25 files changed

+2224
-14
lines changed

.github/actions/shared-steps/action.yml

Lines changed: 126 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ inputs:
4141
runs:
4242
using: "composite"
4343
steps:
44+
- uses: runs-on/action@v2
45+
# only when in runs-on environment
46+
if: env.RUNS_ON_VERSION != ''
47+
with:
48+
metrics: cpu,network,memory,disk,io
4449

4550
- name: Runner OS, install extra packages
4651
shell: bash
@@ -73,14 +78,15 @@ runs:
7378
echo "version_major=${version_major}" >> $GITHUB_ENV
7479
echo "alma_arch=${alma_arch}" >> $GITHUB_ENV
7580
76-
- name: Prepare staff
81+
- name: Prepare stuff
7782
shell: bash
7883
run: |
79-
# Prepare staff
84+
# Prepare stuff
85+
packer_opts=
8086
case ${{ env.runner_os }} in
8187
ubuntu)
8288
# Packer options
83-
packer_opts="-var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
89+
packer_opts="-var qemu_binary=/usr/bin/qemu-system-${{ inputs.arch }} -var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
8490
;;
8591
rhel)
8692
# Packer options
@@ -114,6 +120,10 @@ runs:
114120
# AWS S3 path to store images
115121
aws_s3_path=images/${{ env.version_major }}/${release}/${{ inputs.type }}/${{ env.TIME_STAMP }}
116122
123+
# tell packer we can use more cpu/ram if we're using runs-on
124+
# which means we're using runs-on with metal instances
125+
[[ ${{ env.RUNS_ON_VERSION }} != '' ]] && packer_opts="${packer_opts} -var cpus=$(($(nproc)-4)) -var memory_${{ env.alma_arch }}=32768"
126+
117127
# Overriding packer source, image mask and S3 path where necessary
118128
case "${{ inputs.type }}${{ env.version_major }}" in
119129
azure8|azure9)
@@ -228,6 +238,17 @@ runs:
228238
output_mask=output-${packer_source}/AlmaLinux-*.${{ env.alma_arch }}*.qcow2
229239
packer_source=qemu.${packer_source}
230240
;;
241+
gcp8|gcp9)
242+
output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
243+
packer_source=qemu.${packer_source}
244+
;;
245+
gcp10)
246+
packer_source=almalinux_${{ env.version_major }}_${{ inputs.type }}_${{ env.alma_arch }}
247+
[[ ${{ env.version_major }} == *"v2"* ]] && packer_source="${packer_source}_v2"
248+
[[ ${{ inputs.variant }} == *"64k"* ]] && packer_source="almalinux_${{ env.version_major }}_${{ inputs.type }}_64k_${{ env.alma_arch }}"
249+
output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
250+
packer_source=qemu.${packer_source}
251+
;;
231252
*)
232253
output_mask=output-${output_mask}
233254
packer_source=qemu.${packer_source}
@@ -260,8 +281,24 @@ runs:
260281
;;
261282
esac
262283
284+
- name: Remove KVM
285+
if: inputs.type == 'vagrant_virtualbox' || inputs.type == 'vagrant_vmware'
286+
shell: bash
287+
run: |
288+
# Remove KVM
289+
case ${{ env.runner_os }} in
290+
ubuntu)
291+
sudo apt-get -y remove qemu-kvm
292+
;;
293+
rhel)
294+
sudo dnf -y -q remove qemu-kvm
295+
;;
296+
esac
297+
sudo rmmod kvm_amd || sudo rmmod kvm_intel || true
298+
sudo rmmod kvm || true
299+
263300
- name: Check nested virtualization support
264-
if: inputs.arch == 'x86_64' && inputs.type != 'vagrant_virtualbox' && inputs.type != 'vagrant_vmware' && inputs.runner != 'aws-ec2'
301+
if: inputs.arch == 'x86_64' && env.RUNS_ON_VERSION == '' && inputs.type != 'vagrant_virtualbox' && inputs.type != 'vagrant_vmware'
265302
shell: bash
266303
run: |
267304
# Check nested virtualization support
@@ -365,12 +402,13 @@ runs:
365402
run: |
366403
# Build ${{ inputs.type }} image
367404
# PACKER_LOG=1
405+
sudo systemctl start libvirtd
368406
sudo sh -c "/usr/bin/packer build ${{ env.PACKER_OPTS }} -only=${{ env.packer_source }} ."
369407
370408
- name: Locate image file, generate checksum
371409
shell: bash
372410
run: |
373-
# Locate image file, generate checksum
411+
# Locate image file, generate checksum, rename repo metadata file
374412
ls -la $(dirname '${{ env.output_mask }}')
375413
image_file=$(ls -1 ${{ env.output_mask }} | head -n 1)
376414
[ "x${image_file}" = "x" ] && false
@@ -380,8 +418,79 @@ runs:
380418
echo "IMAGE_FILE=${image_file}" >> $GITHUB_ENV
381419
echo "IMAGE_NAME=$(basename ${image_file})" >> $GITHUB_ENV
382420
383-
# - name: Setup tmate session
384-
# uses: mxschmitt/action-tmate@v3
421+
# don't fail if this doesn't exist, we may not always generate it
422+
sudo mv repo-metadata-*.txt $(basename ${image_file}).repo-metadata.txt || true
423+
424+
- id: 'google-auth-dev-images'
425+
if: env.IMAGE_TYPE == 'gcp'
426+
uses: 'google-github-actions/auth@v2'
427+
with:
428+
workload_identity_provider: 'projects/443728870479/locations/global/workloadIdentityPools/github-actions/providers/github'
429+
service_account: 'github-actions-cloud-images@almalinux-dev-images-469421.iam.gserviceaccount.com'
430+
431+
- name: 'Set up Google Cloud SDK'
432+
if: env.IMAGE_TYPE == 'gcp'
433+
uses: 'google-github-actions/[email protected]'
434+
435+
- name: 'Upload output to GCP storage bucket'
436+
if: env.IMAGE_TYPE == 'gcp'
437+
shell: bash
438+
run: gcloud storage cp ${{ env.IMAGE_FILE }} gs://almalinux-images-dev/almalinux-${version_major}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}-v$(date +'%Y%m%d')/root.tar.gz
439+
440+
- name: Clone gce_image_publish repo
441+
if: env.IMAGE_TYPE == 'gcp'
442+
uses: actions/checkout@v5
443+
with:
444+
path: compute-image-tools
445+
repository: GoogleCloudPlatform/compute-image-tools
446+
ref: "20250916.00"
447+
448+
- name: Build gce_image_publish tool
449+
if: env.IMAGE_TYPE == 'gcp'
450+
shell: bash
451+
run: |
452+
# we need golang
453+
case ${{ env.runner_os }} in
454+
ubuntu)
455+
sudo apt update
456+
sudo apt-get -y install golang-go
457+
;;
458+
rhel)
459+
sudo dnf -y -q install golang
460+
;;
461+
esac
462+
# print golang version for reference
463+
go version
464+
# Build gce_image_publish tool
465+
cd compute-image-tools/cli_tools/gce_image_publish
466+
go mod tidy
467+
go install
468+
469+
- name: Create test image on GCP
470+
if: env.IMAGE_TYPE == 'gcp'
471+
shell: bash
472+
run: |
473+
/home/$USER/go/bin/gce_image_publish \
474+
-var:environment=test \
475+
-skip_confirmation \
476+
-rollout_rate=0 \
477+
-publish_project="almalinux-dev-images-469421" \
478+
-work_project="almalinux-dev-images-469421" \
479+
-replace \
480+
-source_gcs_path="gs://almalinux-images-dev/" \
481+
vm-scripts/gcp/almalinux_${version_major}${{ inputs.arch == 'aarch64' && '_arm64' || '' }}.publish.json
482+
483+
# - name: 'Run Google cloud-image-testing tests (basic suite)'
484+
# if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
485+
# shell: bash
486+
# run: |
487+
# cd cloud-image-tests
488+
# ./bin/manager \
489+
# -local_path bin \
490+
# -project almalinux-image-testing-469421 \
491+
# -filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|lssd|disk|packagevalidation|ssh|metadata|vmspec)$' \
492+
# -images 'projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ env.version_major }}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}' \
493+
# -parallel_stagger 10s -parallel_count 20
385494

386495
- name: Test ${{ inputs.type }} ${{ inputs.variant }} image
387496
# Skip testing for vagrant_virtualbox on GH runner because 'vugrant up' fails to connect to the newly created VM via ssh:
@@ -474,6 +583,15 @@ runs:
474583
name: ${{ env.IMAGE_NAME }}
475584
path: ${{ env.IMAGE_FILE }}
476585

586+
- uses: actions/upload-artifact@v4
587+
name: Store repo metadata as artifact
588+
id: repo-meta-artifact
589+
if: inputs.store_as_artifact == 'true'
590+
with:
591+
compression-level: 9
592+
name: ${{ env.IMAGE_NAME }}.repo-metadata.txt
593+
path: ${{ env.IMAGE_FILE }}.repo-metadata.txt
594+
477595
- uses: actions/upload-artifact@v4
478596
name: Store checksum as artifact
479597
id: checksum-artifact
@@ -488,7 +606,7 @@ runs:
488606
id: pkglist-artifact
489607
if: inputs.store_as_artifact == 'true' && env.got_pkgs_list == 'true'
490608
with:
491-
compression-level: 1
609+
compression-level: 9
492610
name: ${{ env.IMAGE_NAME }}.txt
493611
path: ${{ env.IMAGE_FILE }}.txt
494612

.github/workflows/build.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ on:
3030
- ALL
3131
- azure
3232
# - digitalocean # TODO: require data to work with the cloud, such as: bucket, access key, secret key, etc.
33+
- gcp
3334
- gencloud
3435
- oci
3536
- opennebula
@@ -114,6 +115,10 @@ jobs:
114115
VARIANTS_GH+=("azure-x86_64")
115116
VARIANTS_SH+=("azure-aarch64")
116117
fi
118+
if [ "${{ inputs.image_type }}" = "gcp" -o "${{ inputs.image_type }}" = "ALL" ]; then
119+
VARIANTS_GH+=("gcp-x86_64")
120+
VARIANTS_SH+=("gcp-aarch64")
121+
fi
117122
if [ "${{ inputs.image_type }}" = "digitalocean" -o "${{ inputs.image_type }}" = "ALL" ]; then
118123
if [[ "${{ inputs.version_major }}" != *"kitten"* ]] && [[ "${{ inputs.version_major }}" != *"10" ]]; then
119124
VARIANTS_GH+=("digitalocean-x86_64")
@@ -145,6 +150,14 @@ jobs:
145150
VARIANTS_SH+=("vagrant_vmware-x86_64") # VMware has networking issues on GitHub runners, so we use self-hosted runner
146151
fi
147152
153+
# Add SH values to matrix_gh if using runs-on
154+
if [ "${{ github.repository_owner }}" == 'AlmaLinux' ]; then
155+
for sh in "${VARIANTS_SH[@]}"; do
156+
VARIANTS_GH+=("$sh")
157+
done
158+
unset VARIANTS_SH
159+
fi
160+
148161
[ ${#VARIANTS_GH[@]} -ne 0 ] && matrix_gh=$(printf '"%s",' "${VARIANTS_GH[@]}")
149162
matrix_gh=${matrix_gh%,} # Remove the trailing comma
150163
echo matrix_gh=$(jq -c <<< [${matrix_gh}]) >> $GITHUB_OUTPUT
@@ -173,26 +186,34 @@ jobs:
173186
174187
build-gh-hosted:
175188
name: ${{ matrix.variant }} ${{ matrix.matrix_gh }} image
189+
permissions:
190+
id-token: write
191+
contents: read
176192
needs: [init-data]
177193
if: ${{ needs.init-data.outputs.matrix_gh != '[]' }}
178-
runs-on: ubuntu-24.04
194+
# use runs-on runners if within the almalinux org, otherwise GH runners"
195+
runs-on: "${{ github.repository_owner == 'AlmaLinux' && format('runs-on={0}/family=c7i.metal-24xl+c7a.metal-48xl+*8gd.metal*/image=ubuntu24-full-{2}', github.run_id, matrix.variant, contains(matrix.matrix_gh, 'aarch64') && 'arm64' || 'x64') || 'ubuntu-24.04' }}"
179196
strategy:
180197
fail-fast: false
181198
matrix:
182-
variant: ${{ fromJSON(format('["{0}"]', ( inputs.version_major == '10-kitten' || inputs.version_major == '10' ) && format('{0}", "{0}-v2', inputs.version_major) || inputs.version_major )) }}
199+
variant: ${{ fromJSON(format('["{0}"]', ( (inputs.version_major == '10-kitten' || inputs.version_major == '10') && !(contains(needs.init-data.outputs.matrix_gh, 'aarch64') ) ) && format('{0}", "{0}-v2', inputs.version_major) || inputs.version_major )) }}
183200
matrix_gh: ${{ fromJSON(needs.init-data.outputs.matrix_gh) }}
184201
exclude:
185202
- matrix_gh: 'azure-x86_64'
186203
variant: '10-kitten-v2'
187204
- matrix_gh: 'oci-x86_64'
188205
variant: '10-kitten-v2'
206+
- matrix_gh: 'gcp-x86_64'
207+
variant: '10-kitten-v2'
189208
# Kitten x86_64_v2 Vagrant for VirtualBox stuck on "Waiting for SSH to become available"
190209
- matrix_gh: 'vagrant_virtualbox-x86_64'
191210
variant: '10-kitten-v2'
192211
- matrix_gh: 'digitalocean-x86_64'
193212
variant: '10-kitten-v2'
194213
- matrix_gh: 'azure-x86_64'
195214
variant: '10-v2'
215+
- matrix_gh: 'gcp-x86_64'
216+
variant: '10-v2'
196217
- matrix_gh: 'oci-x86_64'
197218
variant: '10-v2'
198219
- matrix_gh: 'digitalocean-x86_64'
@@ -211,7 +232,7 @@ jobs:
211232
echo "ARCH=$arch" >> $GITHUB_ENV
212233
213234
- name: Checkout ${{ github.action_repository }}
214-
uses: actions/checkout@v4
235+
uses: actions/checkout@v5
215236

216237
- uses: ./.github/actions/shared-steps
217238
name: ${{ matrix.variant }} ${{ matrix.matrix_gh }} image
@@ -232,15 +253,25 @@ jobs:
232253
store_as_artifact: ${{ inputs.store_as_artifact }}
233254
upload_to_s3: ${{ inputs.upload_to_s3 }}
234255
notify_mattermost: ${{ inputs.notify_mattermost }}
235-
run_test: true # Do image simple testing and generate installed packages list (vagrant_* only)
256+
run_test: true # Do image simple testing and generate installed packages list (vagrant_* and GCP only)
236257
# runner: ${{ github.repository_owner == 'AlmaLinux' && 'aws-ec2' || 'gh_hosted' }}
237258
runner: gh_hosted
238259
env:
239260
PACKER_GITHUB_API_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
240261

262+
263+
264+
265+
266+
267+
268+
269+
### Everything below is for self-hosted runners only ###
270+
241271
start-self-hosted-runner:
242272
name: ${{ matrix.variant }} ${{ matrix.matrix_sh }} runner
243-
if: ${{ inputs.self-hosted && needs.init-data.outputs.matrix_sh != '[]' }}
273+
# If we're in the almalinux org we use runs-on for self-hosted
274+
if: ${{ github.repository_owner != 'AlmaLinux' && inputs.self-hosted && needs.init-data.outputs.matrix_sh != '[]' }}
244275
runs-on: ubuntu-24.04
245276
needs: [init-data]
246277
strategy:
@@ -316,6 +347,8 @@ jobs:
316347
exclude:
317348
- matrix_sh: 'oci-aarch64'
318349
variant: '10-kitten'
350+
- matrix_sh: 'oci-aarch64'
351+
variant: '10'
319352
- matrix_sh: 'oci-aarch64'
320353
variant: '9-64k'
321354
- matrix_sh: 'oci-aarch64'

0 commit comments

Comments
 (0)