Skip to content

Commit

Permalink
ci: cluster-autoscaler multiarch build
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-sakhnov committed Oct 29, 2024
1 parent fdb487d commit 3e193a1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 32 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:

strategy:
matrix:
arch: [ 'amd64', 'arm64' ]
arch: [ amd64, arm64 ]
runs-on: ${{ fromJson(format('["self-hosted", "{0}"]', matrix.arch == 'arm64' && 'large-arm64' || 'large')) }}

services:
Expand Down Expand Up @@ -314,19 +314,20 @@ jobs:
build-args: |
GO_BASE_IMG=${{ env.GO_BASE_IMG }}
GIT_INFO=${{ steps.get-git-info.outputs.info }}
# TODO: AUTOSCALER IMAGE IS HARDCODED FOR AMD
# - name: Build and push cluster-autoscaler image
# uses: docker/build-push-action@v6
# if: ${{ format('{0}', inputs.build-cluster-autoscaler) == 'true' }}
# with:
# context: cluster-autoscaler

# push: true
# tags: ${{ needs.tags.outputs.cluster-autoscaler }}
# cache-from: type=registry,ref=cache.neon.build/cluster-autoscaler-neonvm:cache
# cache-to: ${{ github.ref_name == 'main' && 'type=registry,ref=cache.neon.build/cluster-autoscaler-neonvm:cache,mode=max' || '' }}
# build-args: |
# CA_GIT_TAG=${{ steps.get-ca-tag.outputs.tag }}
- name: Build and push cluster-autoscaler image
uses: docker/build-push-action@v6
if: ${{ format('{0}', inputs.build-cluster-autoscaler) == 'true' }}
with:
context: cluster-autoscaler
platforms: linux/${{ matrix.arch }}
push: true
target: ${{format('cluster_autoscaler_{0}', matrix.arch)}}
tags: ${{ needs.tags.outputs.cluster-autoscaler }}
cache-from: type=registry,ref=cache.neon.build/cluster-autoscaler-neonvm:cache
cache-to: ${{ github.ref_name == 'main' && 'type=registry,ref=cache.neon.build/cluster-autoscaler-neonvm:cache,mode=max' || '' }}
build-args: |
CA_GIT_TAG=${{ steps.get-ca-tag.outputs.tag }}
# - name: Copy all images to ECR
# if: ${{ format('{0}', inputs.upload-to-ecr) == 'true' }}
Expand Down
39 changes: 22 additions & 17 deletions .github/workflows/check-ca-builds.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
name: check-cluster-autoscaler-builds
on: {}
# pull_request:
# paths:
# - "cluster-autoscaler/ca.tag"
# - "cluster-autoscaler/ca.patch"
# - "cluster-autoscaler/Dockerfile"
# - ".github/workflows/check-ca-builds.yaml"
# push:
# branches:
# - main
# paths:
# - "cluster-autoscaler/ca.tag"
# - "cluster-autoscaler/ca.patch"
# - "cluster-autoscaler/Dockerfile"
# - ".github/workflows/check-ca-builds.yaml"
on:
pull_request:
paths:
- "cluster-autoscaler/ca.tag"
- "cluster-autoscaler/ca.patch"
- "cluster-autoscaler/Dockerfile"
- ".github/workflows/check-ca-builds.yaml"
push:
branches:
- main
paths:
- "cluster-autoscaler/ca.tag"
- "cluster-autoscaler/ca.patch"
- "cluster-autoscaler/Dockerfile"
- ".github/workflows/check-ca-builds.yaml"

jobs:
build-ca:
runs-on: [ self-hosted, gen3, small ]
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
runs-on: ${{ fromJson(format('["self-hosted", "{0}"]', matrix.arch == 'arm64' && 'large-arm64' || 'large')) }}
steps:
- uses: actions/checkout@v4

Expand All @@ -41,8 +45,9 @@ jobs:
uses: docker/build-push-action@v6
with:
context: cluster-autoscaler
platforms: linux/amd64
platforms: ${{format('linux/{0}', matrix.arch)}}
push: false
target: ${{format('cluster_autoscaler_{0}', matrix.arch)}}
file: cluster-autoscaler/Dockerfile
cache-from: type=registry,ref=cache.neon.build/cluster-autoscaler-neonvm:cache
build-args: |
Expand Down
10 changes: 9 additions & 1 deletion cluster-autoscaler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ RUN cd autoscaler/cluster-autoscaler \
# This is adapted from CA's Dockerfile.amd64, here:
# https://github.com/kubernetes/autoscaler/blob/cluster-autoscaler-1.24.1/cluster-autoscaler/Dockerfile.amd64

FROM gcr.io/distroless/static:nonroot-amd64

# NB: two build stages, one for each architecture, because I wasn't able to use variable substitution in FROM statements
FROM gcr.io/distroless/static:nonroot-amd64 as cluster_autoscaler_amd64

Check warning on line 33 in cluster-autoscaler/Dockerfile

View workflow job for this annotation

GitHub Actions / build-ca (amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 33 in cluster-autoscaler/Dockerfile

View workflow job for this annotation

GitHub Actions / build-ca (arm64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /
COPY --from=builder /workspace/cluster-autoscaler .
CMD ["/cluster-autoscaler"]

FROM gcr.io/distroless/static:nonroot-arm64 as cluster_autoscaler_arm64

Check warning on line 39 in cluster-autoscaler/Dockerfile

View workflow job for this annotation

GitHub Actions / build-ca (amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 39 in cluster-autoscaler/Dockerfile

View workflow job for this annotation

GitHub Actions / build-ca (arm64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /
COPY --from=builder /workspace/cluster-autoscaler .
Expand Down

0 comments on commit 3e193a1

Please sign in to comment.