Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit ecff9f8

Browse files
committed
set up new release tooling for controller/sidecar subrepos
Set up new cloudbuild tooling for the controller/sidecar subrepo layout. Controller and sidecar are both always built pushed to staging with the current git tag (e.g., v20240905-v0.1.0-58-g80979e8) as well as 'latest'. Controller pre-release staging build can be initiated by creating a github release (or tag) in the form `cloudbuild/TAG`. Similarly, sidecar pre-release staging build can be initiated by creating a github release (or tag) in the form `sidecar/TAG`. Signed-off-by: Blaine Gardner <[email protected]>
1 parent e9d5dfb commit ecff9f8

File tree

5 files changed

+81
-81
lines changed

5 files changed

+81
-81
lines changed

Diff for: Makefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ SHELL = /usr/bin/env bash
2020
help: ## Display this help.
2121
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
2222

23+
# If GOARCH is not set in the env, find it
24+
GOARCH ?= $(shell go env GOARCH)
25+
2326
##
2427
## ==== ARGS ===== #
2528

@@ -29,13 +32,15 @@ DOCKER ?= docker
2932
## Platform for 'build'
3033
PLATFORM ?= linux/$(GOARCH)
3134

35+
## Additional args for 'build'
36+
BUILD_ARGS ?=
37+
3238
## Image tag for controller image build
3339
CONTROLLER_TAG ?= cosi-controller:latest
3440

3541
## Image tag for sidecar image build
3642
SIDECAR_TAG ?= cosi-provisioner-sidecar:latest
3743

38-
3944
##@ Development
4045

4146
.PHONY: all .gen
@@ -68,9 +73,9 @@ build: build.controller build.sidecar ## Build all container images for developm
6873

6974
.PHONY: build.controller build.sidecar
7075
build.controller: controller/Dockerfile ## Build only the controller container image
71-
$(DOCKER) build --file controller/Dockerfile --platform $(PLATFORM) --tag $(CONTROLLER_TAG) .
76+
$(DOCKER) build --file controller/Dockerfile --platform $(PLATFORM) $(BUILD_ARGS) --tag $(CONTROLLER_TAG) .
7277
build.sidecar: sidecar/Dockerfile ## Build only the sidecar container image
73-
$(DOCKER) build --file sidecar/Dockerfile --platform $(PLATFORM) --tag $(SIDECAR_TAG) .
78+
$(DOCKER) build --file sidecar/Dockerfile --platform $(PLATFORM) $(BUILD_ARGS) --tag $(SIDECAR_TAG) .
7479

7580
.PHONY: clean
7681
## Clean build environment

Diff for: cloudbuild.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# K8s infra build example: https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
2+
# GCloud build docs: https://cloud.google.com/cloud-build/docs/build-config
3+
# Builds go to https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage/GLOBAL
4+
# Build logs in https://testgrid.k8s.io/sig-storage-image-build
5+
timeout: 3600s
6+
options:
7+
substitution_option: 'ALLOW_LOOSE'
8+
machineType: 'E2_HIGHCPU_8'
9+
substitutions:
10+
# K8s provides custom substitutions _GIT_TAG and _PULL_BASE_REF:
11+
# https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md#custom-substitutions
12+
_GIT_TAG: '12345' # e.g., vYYYYMMDD-hash, vYYYYMMDD-tag, or vYYYYMMDD-tag-n-ghash
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+
_PLATFORMS: linux/amd64,linux/arm64 # add more platforms here if desired
16+
steps:
17+
# TODO: currently gcr.io/k8s-testimages/gcb-docker-gcloud has not moved to Artifact Registry
18+
# gcr.io will be shut down 18 Mar 2025, and we need replacement before then. Latest info below:
19+
# https://github.com/kubernetes/test-infra/blob/master/images/gcb-docker-gcloud/cloudbuild.yaml
20+
- id: do-multi-arch-build-all-images
21+
name: gcr.io/k8s-testimages/gcb-docker-gcloud:v20240718-5ef92b5c36
22+
args:
23+
- hack/cloudbuild.sh
24+
env:
25+
- GIT_TAG=$_GIT_TAG
26+
- PULL_BASE_REF=$_PULL_BASE_REF
27+
- PLATFORM=$_PLATFORMS

Diff for: controller/cloudbuild.yaml

-39
This file was deleted.

Diff for: hack/cloudbuild.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
set -o errexit
3+
set -o nounset
4+
5+
# with nounset, these will fail if necessary vars are missing
6+
echo "GIT_TAG: ${GIT_TAG}"
7+
echo "PULL_BASE_REF: ${PULL_BASE_REF}"
8+
echo "PLATFORM: ${PLATFORM}"
9+
10+
# debug the rest of the script in case of image/CI build issues
11+
set -o xtrace
12+
13+
REPO="gcr.io/k8s-staging-sig-storage"
14+
15+
CONTROLLER_IMAGE="${REPO}/objectstorage-controller"
16+
SIDECAR_IMAGE="${REPO}/objectstorage-sidecar"
17+
18+
# args to 'make build'
19+
export DOCKER="/buildx-entrypoint" # available in gcr.io/k8s-testimages/gcb-docker-gcloud image
20+
export BUILD_ARGS="--push"
21+
export PLATFORM
22+
export SIDECAR_TAG="${SIDECAR_IMAGE}:${GIT_TAG}"
23+
export CONTROLLER_TAG="${CONTROLLER_IMAGE}:${GIT_TAG}"
24+
25+
# build in parallel
26+
make --jobs --output-sync build
27+
28+
# add latest tag to just-built images
29+
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:latest"
30+
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:latest"
31+
32+
# PULL_BASE_REF is 'controller/TAG' for a controller release
33+
if [[ "${PULL_BASE_REF}" == controller/* ]]; then
34+
echo " ! ! ! this is a tagged controller release ! ! !"
35+
TAG="${PULL_BASE_REF#controller/*}"
36+
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:${TAG}"
37+
fi
38+
39+
# PULL_BASE_REF is 'sidecar/TAG' for a controller release
40+
if [[ "${PULL_BASE_REF}" == sidecar/* ]]; then
41+
echo " ! ! ! this is a tagged sidecar release ! ! !"
42+
TAG="${PULL_BASE_REF#sidecar/*}"
43+
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:${TAG}"
44+
fi
45+
46+
# else, PULL_BASE_REF is a branch name (e.g., master, release-0.2) or a tag (e.g., client/v0.2.0, proto/v0.2.0)

Diff for: sidecar/cloudbuild.yaml

-39
This file was deleted.

0 commit comments

Comments
 (0)