1
+ # K8s infra build example: https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
1
2
# GCloud build docs: https://cloud.google.com/cloud-build/docs/build-config
2
3
# Builds go to https://console.cloud.google.com/gcr/images/k8s-staging-test-infra/global/
3
4
# Build logs in https://testgrid.k8s.io/sig-storage-image-build
@@ -6,29 +7,36 @@ options:
6
7
substitution_option : ' ALLOW_LOOSE'
7
8
machineType : ' E2_HIGHCPU_8'
8
9
substitutions :
9
- # GCloud provides som built-in substitution vars:
10
- # https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values
11
10
# K8s provides custom substitutions _GIT_TAG and _PULL_BASE_REF:
12
11
# https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md#custom-substitutions
13
12
_GIT_TAG : ' 12345' # e.g., vYYYYMMDD-hash, vYYYYMMDD-tag, or vYYYYMMDD-tag-n-ghash
14
13
_PULL_BASE_REF : ' master' # e.g., master or release-0.2 for a PR merge, or v0.2 for a tag
14
+ # COSI substitutions:
15
+ _IMAGE : objectstorage-controller
16
+ _PLATFORMS : linux/amd64,linux/arm64 # add more platforms here if desired
15
17
steps :
16
- # based on simple build example
17
- # https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
18
- - name : gcr.io/cloud-builders/docker
19
- # entrypoint: # docker by default
18
+ # based on k8s infra build example and modified to use docker buildx
19
+ # buildx refs: https://github.com/docker/buildx/blob/master/docs/reference/buildx.md
20
+ - id : set-up-multi-arch-builder-as-default
21
+ name : gcr.io/cloud-builders/docker
22
+ args : ["buildx", "create", "--use", "--name", "multi-arch", "--platform=${_PLATFORMS}"]
23
+ - id : bootstrap-multi-arch-builder
24
+ name : gcr.io/cloud-builders/docker
25
+ args : ["buildx", "inspect", "--bootstrap"]
26
+ - id : do-multi-arch-build
27
+ name : gcr.io/cloud-builders/docker
20
28
args :
21
29
- buildx
22
30
- build
23
- - --platform=linux/amd64,linux/arm64
24
- - --tag=gcr.io/k8s-staging-sig-storage/objectstorage-controller :${_GIT_TAG}
31
+ - --platform=${_PLATFORMS}
32
+ - --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE} :${_GIT_TAG}
25
33
# using _PULL_BASE_REF as a tag will often just build and overwrite the same 'master' tag,
26
34
# BUT! if the commit has a git tag, it will build that tag instead. this mechanism allows
27
35
# creating the semver-tagged images that will be auto-promoted to release
28
- - --tag=gcr.io/k8s-staging-sig-storage/objectstorage-controller :${_PULL_BASE_REF}
29
- - --tag=gcr.io/k8s-staging-sig-storage/objectstorage-controller :latest
36
+ - --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE} :${_PULL_BASE_REF}
37
+ - --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE} :latest
30
38
- .
31
39
images :
32
- - gcr.io/k8s-staging-sig-storage/objectstorage-controller :${_GIT_TAG}
33
- - gcr.io/k8s-staging-sig-storage/objectstorage-controller :${_PULL_BASE_REF}
34
- - gcr.io/k8s-staging-sig-storage/objectstorage-controller :latest
40
+ - gcr.io/k8s-staging-sig-storage/${_IMAGE} :${_GIT_TAG}
41
+ - gcr.io/k8s-staging-sig-storage/${_IMAGE} :${_PULL_BASE_REF}
42
+ - gcr.io/k8s-staging-sig-storage/${_IMAGE} :latest
0 commit comments