Skip to content

Commit c722fc3

Browse files
authored
Build Arm images from this repo using Github-hosted Arm runners (antrea-io#6486)
Github-hosted Arm runners are now in Beta for Enterprise accounts, and available to all CNCF projects. We can use them to build Antrea Arm images for the Agent and Controller, instead of relying on a private Github repo with self-hosted Arm runners. At the moment, we only migrate the building part (along with creation of the multi-image manifest), and we use the existing workflow in vmware-tanzu/antrea-build-infra for "asynchronous" testing of the Arm images. We will handle the migration of the testing part in the future. As part of this change, we also push "base images" (antrea/openvswitch, antrea/base-ubuntu) for arm64 and arm/v7 to the registry. This is necessary for building the Antrea images with the Docker container build driver. The base images now have the architecture as a suffix in their names. They are not available as multi-platform image manifests. For antrea-io#6453 Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
1 parent aeb03b0 commit c722fc3

18 files changed

+217
-122
lines changed

.github/workflows/build.yml

+102-68
Original file line numberDiff line numberDiff line change
@@ -13,72 +13,115 @@ on:
1313
- feature/*
1414

1515
jobs:
16-
check-changes:
17-
name: Check whether tests need to be run based on diff
18-
runs-on: [ubuntu-latest]
16+
check-env:
17+
name: Compute outputs for use by other jobs
18+
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
2323
show-progress: false
24-
- uses: antrea-io/has-changes@v2
24+
- name: Check whether tests need to be run based on diff
25+
uses: antrea-io/has-changes@v2
2526
id: check_diff
2627
with:
2728
paths-ignore: docs/* ci/jenkins/* *.md hack/.notableofcontents
29+
- name: Checking if image needs to be pushed
30+
id: check_push
31+
run: |
32+
if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
33+
echo "push_needed=true" >> $GITHUB_OUTPUT
34+
echo "docker_driver=docker-container" >> $GITHUB_OUTPUT
35+
else
36+
echo "push_needed=false" >> $GITHUB_OUTPUT
37+
echo "docker_driver=docker" >> $GITHUB_OUTPUT
38+
fi
2839
outputs:
2940
has_changes: ${{ steps.check_diff.outputs.has_changes }}
41+
push_needed: ${{ steps.check_push.outputs.push_needed }}
42+
docker_driver: ${{ steps.check_push.outputs.docker_driver }}
3043

3144
build:
32-
needs: check-changes
33-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
34-
runs-on: [ubuntu-latest]
45+
needs: check-env
46+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
47+
strategy:
48+
matrix:
49+
include:
50+
- platform: linux/amd64
51+
runner: ubuntu-latest
52+
suffix: amd64
53+
- platform: linux/arm64
54+
runner: github-arm64-2c-8gb
55+
suffix: arm64
56+
- platform: linux/arm/v7
57+
runner: github-arm64-2c-8gb
58+
suffix: arm
59+
runs-on: ${{ matrix.runner }}
60+
env:
61+
DOCKER_TAG: latest
3562
steps:
3663
- uses: actions/checkout@v4
3764
with:
3865
show-progress: false
39-
- name: Checking if image needs to be pushed
40-
run: |
41-
if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
42-
echo "push_needed=true" >> $GITHUB_ENV
43-
echo "docker_driver=docker-container" >> $GITHUB_ENV
44-
else
45-
echo "push_needed=false" >> $GITHUB_ENV
46-
echo "docker_driver=docker" >> $GITHUB_ENV
47-
fi
4866
- name: Set up Docker Buildx
4967
uses: docker/setup-buildx-action@v3
5068
with:
51-
driver: ${{ env.docker_driver }}
52-
- name: Build Antrea amd64 Docker image without pushing to registry
53-
if: ${{ env.push_needed == 'false' }}
69+
driver: ${{ needs.check-env.outputs.docker_driver }}
70+
- name: Build Antrea Docker image without pushing to registry
71+
if: ${{ needs.check-env.outputs.push_needed == 'false' }}
5472
run: |
55-
./hack/build-antrea-linux-all.sh --pull
56-
- name: Build and push Antrea amd64 Docker image to registry
57-
if: ${{ env.push_needed == 'true' }}
73+
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull
74+
- name: Build and push Antrea Docker image to registry
75+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
5876
env:
5977
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
6078
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
6179
run: |
6280
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
63-
./hack/build-antrea-linux-all.sh --pull --push-base-images
64-
docker tag antrea/antrea-controller-ubuntu:latest antrea/antrea-controller-ubuntu-amd64:latest
65-
docker tag antrea/antrea-agent-ubuntu:latest antrea/antrea-agent-ubuntu-amd64:latest
66-
docker push antrea/antrea-controller-ubuntu-amd64:latest
67-
docker push antrea/antrea-agent-ubuntu-amd64:latest
68-
- name: Trigger Antrea arm builds and multi-arch manifest update
69-
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
70-
uses: benc-uk/workflow-dispatch@v1
81+
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull --push-base-images
82+
docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
83+
docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
84+
docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
85+
docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
86+
87+
push-manifest:
88+
needs: [check-env, build]
89+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
90+
runs-on: ubuntu-latest
91+
env:
92+
DOCKER_TAG: latest
93+
steps:
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
7196
with:
72-
repo: vmware-tanzu/antrea-build-infra
73-
ref: refs/heads/main
74-
workflow: Build Antrea ARM images and push manifest
75-
token: ${{ secrets.ANTREA_BUILD_INFRA_WORKFLOW_DISPATCH_PAT }}
76-
inputs: ${{ format('{{ "antrea-repository":"antrea-io/antrea", "antrea-ref":"{0}", "docker-tag":"{1}" }}', github.ref, 'latest') }}
97+
driver: ${{ needs.check-env.outputs.docker_driver }}
98+
- name: Docker login
99+
env:
100+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
101+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
102+
run: |
103+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
104+
- name: Create and push manifest for controller image
105+
run: |
106+
docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \
107+
antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
108+
antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
109+
antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
110+
docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}"
111+
- name: Create and push manifest for agent image
112+
run: |
113+
docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \
114+
antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
115+
antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
116+
antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
117+
docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}"
77118
78119
build-ubi:
79-
needs: check-changes
80-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
81-
runs-on: [ubuntu-latest]
120+
needs: check-env
121+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
122+
runs-on: ubuntu-latest
123+
env:
124+
DOCKER_TAG: latest
82125
steps:
83126
- name: Free disk space
84127
# https://github.com/actions/virtual-environments/issues/709
@@ -88,40 +131,31 @@ jobs:
88131
- uses: actions/checkout@v4
89132
with:
90133
show-progress: false
91-
- name: Checking if image needs to be pushed
92-
run: |
93-
if [ "${{ github.repository }}" == "antrea-io/antrea" ] && [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
94-
echo "push_needed=true" >> $GITHUB_ENV
95-
echo "docker_driver=docker-container" >> $GITHUB_ENV
96-
else
97-
echo "push_needed=false" >> $GITHUB_ENV
98-
echo "docker_driver=docker" >> $GITHUB_ENV
99-
fi
100134
- name: Set up Docker Buildx
101135
uses: docker/setup-buildx-action@v3
102136
with:
103-
driver: ${{ env.docker_driver }}
137+
driver: ${{ needs.check-env.outputs.docker_driver }}
104138
- uses: actions/setup-go@v5
105139
with:
106140
go-version-file: 'go.mod'
107141
- name: Build Antrea UBI9 Docker image without pushing to registry
108-
if: ${{ env.push_needed == 'false' }}
142+
if: ${{ needs.check-env.outputs.push_needed == 'false' }}
109143
run: |
110144
./hack/build-antrea-linux-all.sh --pull --distro ubi
111145
- name: Build and push Antrea UBI9 Docker image to registry
112-
if: ${{ env.push_needed == 'true' }}
146+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
113147
env:
114148
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
115149
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
116150
run: |
117151
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
118152
./hack/build-antrea-linux-all.sh --pull --push-base-images --distro ubi
119-
docker push antrea/antrea-agent-ubi:latest
120-
docker push antrea/antrea-controller-ubi:latest
153+
docker push antrea/antrea-agent-ubi:"${DOCKER_TAG}"
154+
docker push antrea/antrea-controller-ubi:"${DOCKER_TAG}"
121155
122156
build-scale:
123-
needs: check-changes
124-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
157+
needs: check-env
158+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
125159
runs-on: [ubuntu-latest]
126160
steps:
127161
- uses: actions/checkout@v4
@@ -130,7 +164,7 @@ jobs:
130164
- name: Build Antrea Agent Simulator Docker image
131165
run: make build-scale-simulator
132166
- name: Push Antrea Agent Simulator Docker image to registry
133-
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
167+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
134168
env:
135169
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
136170
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@@ -139,18 +173,18 @@ jobs:
139173
docker push antrea/antrea-ubuntu-simulator:latest
140174
141175
build-windows:
142-
needs: check-changes
143-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
176+
needs: check-env
177+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
144178
runs-on: [ubuntu-latest]
145179
steps:
146180
- uses: actions/checkout@v4
147181
with:
148182
show-progress: false
149183
- name: Build Antrea Windows Docker image
150-
if: ${{ github.repository != 'antrea-io/antrea' || github.event_name != 'push' || github.ref != 'refs/heads/main' }}
184+
if: ${{ needs.check-env.outputs.push_needed == 'false' }}
151185
run: ./hack/build-antrea-windows-all.sh --pull
152186
- name: Push Antrea Windows Docker image to registry
153-
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
187+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
154188
env:
155189
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
156190
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@@ -160,8 +194,8 @@ jobs:
160194
shell: bash
161195

162196
build-antrea-mc-controller:
163-
needs: check-changes
164-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
197+
needs: check-env
198+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
165199
runs-on: [ubuntu-latest]
166200
steps:
167201
- uses: actions/checkout@v4
@@ -170,7 +204,7 @@ jobs:
170204
- name: Build antrea-mc-controller Docker image
171205
run: make build-antrea-mc-controller
172206
- name: Push antrea-mc-controller Docker image to registry
173-
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
207+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
174208
env:
175209
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
176210
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@@ -179,8 +213,8 @@ jobs:
179213
docker push antrea/antrea-mc-controller:latest
180214
181215
build-flow-aggregator:
182-
needs: check-changes
183-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
216+
needs: check-env
217+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
184218
runs-on: [ubuntu-latest]
185219
steps:
186220
- uses: actions/checkout@v4
@@ -191,7 +225,7 @@ jobs:
191225
- name: Check flow-aggregator Docker image
192226
run: docker run antrea/flow-aggregator --version
193227
- name: Push flow-aggregator Docker image to registry
194-
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
228+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
195229
env:
196230
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
197231
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@@ -200,8 +234,8 @@ jobs:
200234
docker push antrea/flow-aggregator:latest
201235
202236
build-antrea-migrator:
203-
needs: check-changes
204-
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
237+
needs: check-env
238+
if: ${{ needs.check-env.outputs.has_changes == 'yes' || github.event_name == 'push' }}
205239
runs-on: [ubuntu-latest]
206240
steps:
207241
- uses: actions/checkout@v4
@@ -210,7 +244,7 @@ jobs:
210244
- name: Build antrea-migrator Docker image
211245
run: make build-migrator
212246
- name: Push antrea-migrator Docker image to registry
213-
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
247+
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
214248
env:
215249
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
216250
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/build_tag.yml

+55-11
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,22 @@ jobs:
2020
echo "version=$version" >> $GITHUB_OUTPUT
2121
2222
build:
23-
runs-on: [ubuntu-latest]
2423
needs: get-version
24+
strategy:
25+
matrix:
26+
include:
27+
- platform: linux/amd64
28+
runner: ubuntu-latest
29+
suffix: amd64
30+
- platform: linux/arm64
31+
runner: github-arm64-2c-8gb
32+
suffix: arm64
33+
- platform: linux/arm/v7
34+
runner: github-arm64-2c-8gb
35+
suffix: arm
36+
runs-on: ${{ matrix.runner }}
37+
env:
38+
DOCKER_TAG: ${{ needs.get-version.outputs.version }}
2539
steps:
2640
- uses: actions/checkout@v4
2741
with:
@@ -30,26 +44,54 @@ jobs:
3044
uses: docker/setup-buildx-action@v3
3145
with:
3246
driver: docker
33-
- name: Build and push Antrea Ubuntu amd64 Docker image to registry
47+
- name: Build and push Antrea Ubuntu Docker image to registry
3448
env:
3549
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
3650
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
37-
VERSION: ${{ needs.get-version.outputs.version }}
3851
run: |
39-
./hack/build-antrea-linux-all.sh --pull
52+
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull
4053
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
41-
docker tag antrea/antrea-agent-ubuntu:"${VERSION}" antrea/antrea-agent-ubuntu-amd64:"${VERSION}"
42-
docker tag antrea/antrea-controller-ubuntu:"${VERSION}" antrea/antrea-controller-ubuntu-amd64:"${VERSION}"
43-
docker push antrea/antrea-agent-ubuntu-amd64:"${VERSION}"
44-
docker push antrea/antrea-controller-ubuntu-amd64:"${VERSION}"
45-
- name: Trigger Antrea arm builds and multi-arch manifest update
54+
docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
55+
docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
56+
docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
57+
docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
58+
59+
push-manifest:
60+
needs: build
61+
runs-on: ubuntu-latest
62+
env:
63+
DOCKER_TAG: ${{ needs.get-version.outputs.version }}
64+
steps:
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
- name: Docker login
68+
env:
69+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
70+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
71+
run: |
72+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
73+
- name: Create and push manifest for controller image
74+
run: |
75+
docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \
76+
antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
77+
antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
78+
antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
79+
docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}"
80+
- name: Create and push manifest for agent image
81+
run: |
82+
docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \
83+
antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
84+
antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
85+
antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
86+
docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}"
87+
- name: Trigger Antrea arm tests
4688
uses: benc-uk/workflow-dispatch@v1
4789
with:
4890
repo: vmware-tanzu/antrea-build-infra
4991
ref: refs/heads/main
50-
workflow: Build Antrea ARM images and push manifest
92+
workflow: Test Antrea ARM images
5193
token: ${{ secrets.ANTREA_BUILD_INFRA_WORKFLOW_DISPATCH_PAT }}
52-
inputs: ${{ format('{{ "antrea-repository":"antrea-io/antrea", "antrea-ref":"{0}", "docker-tag":"{1}" }}', github.ref, needs.get-version.outputs.version) }}
94+
inputs: ${{ format('{{ "antrea-repository":"antrea-io/antrea", "antrea-ref":"{0}", "docker-tag":"{1}" }}', github.ref, env.DOCKER_TAG) }}
5395

5496
build-ubi:
5597
runs-on: [ubuntu-latest]
@@ -58,6 +100,8 @@ jobs:
58100
- uses: actions/checkout@v4
59101
with:
60102
show-progress: false
103+
- name: Set up Docker Buildx
104+
uses: docker/setup-buildx-action@v3
61105
- name: Build and push Antrea UBI9 amd64 Docker image to registry
62106
env:
63107
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}

0 commit comments

Comments
 (0)