Skip to content
Open
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
91 changes: 91 additions & 0 deletions .github/workflows/build-azure-capi-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build Azure CAPI VM image

on:
workflow_dispatch:
inputs:
version:
description: Kuberentes version
required: true
type: string
tag:
description: ck8s-capi tag
required: true
type: string
builder_image:
description: image builder image
required: true
type: string
default: "ghcr.io/elastisys/image-builder-amd64:main"

workflow_call:
inputs:
version:
description: Kubernetes version
required: true
type: string
tag:
description: ck8s-capi tag
required: true
type: string
builder_image:
description: image builder image
required: true
type: string
default: "ghcr.io/elastisys/image-builder-amd64:main"

env:
version: ${{ inputs.version }}
tag: ${{ inputs.tag }}
docker_image: ${{ inputs.builder_image }}

defaults:
run:
working-directory: ./images/capi
shell: bash

jobs:
build-image:
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@v5

- name: replace variables
run: |
package="${version}-1.1"
series="${version%.*}"

sed -r \
-e "s/\\\$KUBERNETES_SERIES/${series}/" \
-e "s/\\\$KUBERNETES_VERSION/${version}/" \
-e "s/\\\$KUBERNETES_DEB_VERSION/${package}/" \
-e "s/\\\$IMAGE_TAG/${tag}/" \
<"template.json" >"kubernetes.json"

- name: build azure image
run: |
image_name="ubuntu-2404-kube-${version%%-*}-ck8s-capi-${tag}"

export SIG_IMAGE_DEFINITION="${image_name}"
export SIG_PUBLISHER="elastisys"
export SIG_OFFER="ck8s-capi"
export SIG_SKU="${image_name}"

docker run -i --rm \
-e PACKER_VAR_FILES -e PACKER_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} \
-e SIG_IMAGE_DEFINITION -e SIG_PUBLISHER -e SIG_OFFER -e SIG_SKU \
-e AZURE_SUBSCRIPTION_ID -e AZURE_CLIENT_ID -e AZURE_CLIENT_SECRET -e AZURE_TENANT_ID -e AZURE_LOCATION \
-e RESOURCE_GROUP_NAME -e GALLERY_NAME -e BUILD_RESOURCE_GROUP_NAME \
-v ${{ github.workspace }}/images/capi:/tmp/host \
${{ env.docker_image }} build-azure-sig-ubuntu-2404-gen2

env:
PACKER_VAR_FILES: /tmp/host/kubernetes.json
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
RESOURCE_GROUP_NAME: ${{ secrets.RESOURCE_GROUP_NAME }}
GALLERY_NAME: ${{ secrets.GALLERY_NAME }}
BUILD_RESOURCE_GROUP_NAME: ${{ secrets.RESOURCE_GROUP_NAME }}
38 changes: 38 additions & 0 deletions .github/workflows/build-capi-vm-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build CAPI VM image with manual input

on:
workflow_dispatch:
inputs:
version:
description: k8s version
required: true
type: string
default: "1.33.1"
tag:
description: ck8s capi version
required: true
type: string
default: "0.8"
builder_image:
description: image builder image
required: true
type: string
default: "ghcr.io/elastisys/image-builder-amd64:main"

env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-azure-image:
uses: ./.github/workflows/build-azure-capi-image.yml
with:
version: ${{ inputs.version }}
tag: ${{ inputs.tag }}
docker_image: ${{ inputs.docker_image }}
secrets: inherit
build-openstack-image:
uses: ./.github/workflows/build-openstack-capi-image.yml
with:
version: ${{ inputs.version }}
tag: ${{ inputs.tag }}
docker_image: ${{ inputs.docker_image }}
33 changes: 33 additions & 0 deletions .github/workflows/build-image-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build CAPI image builder

on:
push:
branches:
- main

env:
IMAGE_NAME: image-builder
REGISTRY: ghcr.io/elastisys

jobs:
build-image-builder:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5

- name: "Login to GitHub Container Registry"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: run make docker-build
run: make docker-build
env:
TAG: main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: This would overwrite the main tag each time? Wouldn't we also want the commit hash to be able to use older builds if needed?
Maybe both, so you can reference the latest build with main but also have a copy of each commit?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create an issue for that as a CI task

@Xartos Xartos Feb 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Can't find this target in the root Makefile. I assume this is this target. If so wouldn't we need to add this?

Suggested change
TAG: main
TAG: main
working-directory: ./images/capi

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have unintentionally removed the working-directory


- name: run make docker-push
run: make docker-push
env:
TAG: main
93 changes: 93 additions & 0 deletions .github/workflows/build-openstack-capi-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build OpenStack VM CAPI image

on:
workflow_dispatch:
inputs:
version:
description: Kubernetes version
required: true
type: string
tag:
description: ck8s-capi tag
required: true
type: string
builder_image:
description: image builder image
required: true
type: string
default: "ghcr.io/elastisys/image-builder-amd64:main"

workflow_call:
inputs:
version:
description: Kubernetes version
required: true
type: string
tag:
description: ck8s-capi tag
required: true
type: string
builder_image:
description: image builder image
required: true
type: string
default: "ghcr.io/elastisys/image-builder-amd64:main"


env:
version: ${{ inputs.version }}
tag: ${{ inputs.tag }}
docker_image: ${{ inputs.builder_image }}

defaults:
run:
working-directory: ./images/capi
shell: bash

jobs:
build-image:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v5

- name: run patchs
run: |
git apply patches/dockerfile.patch

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: replace variables
run: |
package="${version}-1.1"
series="${version%.*}"

sed -r \
-e "s/\\\$KUBERNETES_SERIES/${series}/" \
-e "s/\\\$KUBERNETES_VERSION/${version}/" \
-e "s/\\\$KUBERNETES_DEB_VERSION/${package}/" \
-e "s/\\\$IMAGE_TAG/${tag}/" \
<"template.json" >"kubernetes.json"

- name: add user
run: |
mkdir -p ${{ github.workspace }}/output
sudo useradd -ms /bin/bash imagebuilder
sudo chmod -R 777 ${{ github.workspace }}/output

- name: build openstack image
run: |
docker run --device=/dev/kvm -i --rm \
-e PACKER_VAR_FILES=/tmp/host/kubernetes.json -e PACKER_LOG -e PACKER_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} \
-v ${{ github.workspace }}/images/capi:/tmp/host -v ${{ github.workspace }}/output:/home/imagebuilder/output:rw \
${{ env.docker_image }} build-qemu-ubuntu-2404-efi

- name: store openstack image
uses: actions/upload-artifact@v4
with:
name: ubuntu-2404-efi-kube-${{ env.version }}-ck8s-capi-${{ env.tag }}
path: ${{ github.workspace }}/output/ubuntu-2404-efi-kube-${{ env.version }}-ck8s-capi-${{ env.tag }}
1 change: 1 addition & 0 deletions images/capi/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
!packer
!Makefile
!azure_targets.sh
!template.json
Loading