Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ chore: workflow to build and publish AMIs #5138

Merged
merged 1 commit into from
Oct 8, 2024
Merged
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-ami.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: build-and-publish-ami

on:
workflow_dispatch:
inputs:
regions:
description: 'Publication regions'
required: true
default: 'ap-south-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-2,ap-northeast-1,sa-east-1,ca-central-1,ap-southeast-1,ap-southeast-2,eu-central-1,us-east-1,us-east-2,us-west-1,us-west-2'
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these map to where k8s infra's running?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Which are the historical regions we published AMIs to. We can scope this down in the future.

k8s_semver:
description: 'K8s Semver'
required: true
k8s_series:
description: 'K8s Release Series (major.minor version)'
required: true
k8s_rpm_version:
description: 'K8s rpm package version'
required: true
k8s_deb_version:
description: 'K8s deb package version'
required: true
cni_semver:
description: 'CNI Semver'
required: true
cni_deb_version:
description: 'CNI deb package version'
required: true
crictl_version:
description: 'Crictl version'
required: true

permissions:
id-token: write
contents: read

jobs:
buildandpublish:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
strategy:
matrix:
target: ['ubuntu-2204', 'ubuntu-2404', 'flatcar', 'rhel-8']
name: Build and publish CAPA AMIs
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
repository: kubernetes-sigs/image-builder
fetch-depth: 0
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::819546954734:role/gh-image-builder
- name: Install deps
run: make deps-ami
working-directory: ./images/capi
- name: Install Amazon EBS Plugin
working-directory: ./images/capi
run: ./.local/bin/packer plugins install github.com/hashicorp/amazon
- name: Create Packer Args
env:
K8S_RPM_VERSION: ${{ inputs.k8s_rpm_version }}
K8S_SEMVER: ${{ inputs.k8s_semver }}
K8S_SERIES: ${{ inputs.k8s_series }}
K8S_DEB_VERSION: ${{ inputs.k8s_deb_version }}
CNI_SEMVER: ${{ inputs.cni_semver }}
CNI_DEB_VERSION: ${{ inputs.cni_deb_version }}
CRICTL_VERSION: ${{ inputs.crictl_version }}
AMI_REGIONS: ${{ inputs.regions }}
run: |
cat > ./images/capi/vars.json << EOF
{
"kubernetes_rpm_version": "$K8S_RPM_VERSION",
"kubernetes_semver": "$K8S_SEMVER",
"kubernetes_series": "$K8S_SERIES",
"kubernetes_deb_version": "$K8S_DEB_VERSION",
"kubernetes_cni_semver": "$CNI_SEMVER",
"kubernetes_cni_deb_version": "$CNI_DEB_VERSION",
"crictl_version": "$CRICTL_VERSION",
"ami_regions": "$AMI_REGIONS"
}
EOF
- name: Show vars
run: cat ./images/capi/vars.json
- name: Build AMI
working-directory: ./images/capi
run: PACKER_VAR_FILES=vars.json make build-ami-${{ matrix.target }}

Loading