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

set up new release tooling for controller/sidecar subrepos #97

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions .prow.sh

This file was deleted.

11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ SHELL = /usr/bin/env bash
help: ## Display this help.
@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)

# If GOARCH is not set in the env, find it
GOARCH ?= $(shell go env GOARCH)

##
## ==== ARGS ===== #

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

## Additional args for 'build'
BUILD_ARGS ?=

## Image tag for controller image build
CONTROLLER_TAG ?= cosi-controller:latest

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


##@ Development

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

.PHONY: build.controller build.sidecar
build.controller: controller/Dockerfile ## Build only the controller container image
$(DOCKER) build --file controller/Dockerfile --platform $(PLATFORM) --tag $(CONTROLLER_TAG) .
$(DOCKER) build --file controller/Dockerfile --platform $(PLATFORM) $(BUILD_ARGS) --tag $(CONTROLLER_TAG) .
build.sidecar: sidecar/Dockerfile ## Build only the sidecar container image
$(DOCKER) build --file sidecar/Dockerfile --platform $(PLATFORM) --tag $(SIDECAR_TAG) .
$(DOCKER) build --file sidecar/Dockerfile --platform $(PLATFORM) $(BUILD_ARGS) --tag $(SIDECAR_TAG) .

.PHONY: clean
## Clean build environment
Expand Down
27 changes: 27 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# K8s infra build example: https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
# GCloud build docs: https://cloud.google.com/cloud-build/docs/build-config
# Builds go to https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage/GLOBAL
# Build logs in https://testgrid.k8s.io/sig-storage-image-build
timeout: 3600s
options:
substitution_option: 'ALLOW_LOOSE'
machineType: 'E2_HIGHCPU_8'
substitutions:
# K8s provides custom substitutions _GIT_TAG and _PULL_BASE_REF:
# https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md#custom-substitutions
_GIT_TAG: '12345' # e.g., vYYYYMMDD-hash, vYYYYMMDD-tag, or vYYYYMMDD-tag-n-ghash
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just leave it as an empty string?

Copy link
Contributor Author

@BlaineEXE BlaineEXE Sep 17, 2024

Choose a reason for hiding this comment

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

This is copy-pasted from the previous cloudbuild files -- copy-pasted from an example that I found in some docs. I don't know exactly why, but IIRC it was in the example file as well, so it seemed like it might have some use for testing/validation.

_PULL_BASE_REF: 'master' # e.g., master or release-0.2 for a PR merge, or v0.2 for a tag
# COSI substitutions:
_PLATFORMS: linux/amd64,linux/arm64 # add more platforms here if desired
steps:
# TODO: currently gcr.io/k8s-testimages/gcb-docker-gcloud has not moved to Artifact Registry
# gcr.io will be shut down 18 Mar 2025, and we need replacement before then. Latest info below:
# https://github.com/kubernetes/test-infra/blob/master/images/gcb-docker-gcloud/cloudbuild.yaml
- id: do-multi-arch-build-all-images
name: gcr.io/k8s-testimages/gcb-docker-gcloud:v20240718-5ef92b5c36
args:
- hack/cloudbuild.sh
env:
- GIT_TAG=$_GIT_TAG
- PULL_BASE_REF=$_PULL_BASE_REF
- PLATFORM=$_PLATFORMS
39 changes: 0 additions & 39 deletions controller/cloudbuild.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions hack/cloudbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset

# with nounset, these will fail if necessary vars are missing
echo "GIT_TAG: ${GIT_TAG}"
echo "PULL_BASE_REF: ${PULL_BASE_REF}"
echo "PLATFORM: ${PLATFORM}"

# debug the rest of the script in case of image/CI build issues
set -o xtrace

REPO="gcr.io/k8s-staging-sig-storage"

CONTROLLER_IMAGE="${REPO}/objectstorage-controller"
SIDECAR_IMAGE="${REPO}/objectstorage-sidecar"

# args to 'make build'
export DOCKER="/buildx-entrypoint" # available in gcr.io/k8s-testimages/gcb-docker-gcloud image
export BUILD_ARGS="--push"
export PLATFORM
export SIDECAR_TAG="${SIDECAR_IMAGE}:${GIT_TAG}"
export CONTROLLER_TAG="${CONTROLLER_IMAGE}:${GIT_TAG}"

# build in parallel
make --jobs --output-sync build
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any benefit for multiprocessing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my local testing, this increases the build speed, but it isn't significant. Maybe a 20-30% improvement. I am also testing on macos where the linux native tools don't run as efficiently. It would be hard to guess whether the improvement on the linux build environments would be more or less impactful.


# add latest tag to just-built images
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:latest"
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:latest"

# PULL_BASE_REF is 'controller/TAG' for a controller release
if [[ "${PULL_BASE_REF}" == controller/* ]]; then
echo " ! ! ! this is a tagged controller release ! ! !"
TAG="${PULL_BASE_REF#controller/*}"
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:${TAG}"
fi

# PULL_BASE_REF is 'sidecar/TAG' for a controller release
if [[ "${PULL_BASE_REF}" == sidecar/* ]]; then
echo " ! ! ! this is a tagged sidecar release ! ! !"
TAG="${PULL_BASE_REF#sidecar/*}"
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:${TAG}"
fi

# 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)
39 changes: 0 additions & 39 deletions sidecar/cloudbuild.yaml

This file was deleted.