Skip to content

Commit db095fa

Browse files
committed
release-tools: update
Commit summary: 340e082 build.make: optional inclusion of Windows in multiarch images 5231f05 build.make: properly declare push-multiarch 4569f27 build.make: fix push-multiarch ambiguity bd41690 cloud build: initial set of shared files 6f2322e Update patch release notes generation command d8c76fe Support local snapshot RBAC for pull jobs ea1f94a update release tools instructions 7edc146 Update snapshotter to version 2.0.1 3863a0f build for multiple platforms only in CI, add s390x
2 parents 17e94e4 + be902f4 commit db095fa

File tree

5 files changed

+185
-31
lines changed

5 files changed

+185
-31
lines changed

release-tools/SIDECAR_RELEASE_PROCESS.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,22 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
5050
## Release Process
5151
1. Identify all issues and ongoing PRs that should go into the release, and
5252
drive them to resolution.
53-
1. Download [K8s release notes
53+
1. Download v2.8+ [K8s release notes
5454
generator](https://github.com/kubernetes/release/tree/master/cmd/release-notes)
5555
1. Generate release notes for the release. Replace arguments with the relevant
5656
information.
57-
```
58-
GITHUB_TOKEN=<token> ./release-notes --start-sha=0ed6978fd199e3ca10326b82b4b8b8e916211c9b --end-sha=3cb3d2f18ed8cb40371c6d8886edcabd1f27e7b9 \
59-
--github-org=kubernetes-csi --github-repo=external-attacher -branch=master -output out.md
60-
```
61-
* `--start-sha` should point to the last release from the same branch. For
62-
example:
63-
* `1.X-1.0` tag when releasing `1.X.0`
64-
* `1.X.Y-1` tag when releasing `1.X.Y`
57+
* For new minor releases on master:
58+
```
59+
GITHUB_TOKEN=<token> release-notes --discover=mergebase-to-latest
60+
--github-org=kubernetes-csi --github-repo=external-provisioner
61+
--required-author="" --output out.md
62+
```
63+
* For new patch releases on a release branch:
64+
```
65+
GITHUB_TOKEN=<token> release-notes --discover=patch-to-latest --branch=release-1.1
66+
--github-org=kubernetes-csi --github-repo=external-provisioner
67+
--required-author="" --output out.md
68+
```
6569
1. Compare the generated output to the new commits for the release to check if
6670
any notable change missed a release note.
6771
1. Reword release notes as needed. Make sure to check notes for breaking

release-tools/build.make

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,30 @@ else
6060
TESTARGS =
6161
endif
6262

63-
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
64-
6563
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
6664
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
6765

68-
build-%: check-go-version-go
66+
# BUILD_PLATFORMS contains a set of <os> <arch> <suffix> triplets,
67+
# separated by semicolon. An empty variable or empty entry (= just a
68+
# semicolon) builds for the default platform of the current Go
69+
# toolchain.
70+
BUILD_PLATFORMS =
71+
72+
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
73+
# defined by BUILD_PLATFORMS.
74+
$(CMDS:%=build-%): build-%: check-go-version-go
6975
mkdir -p bin
70-
CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
71-
if [ "$$ARCH" = "amd64" ]; then \
72-
CGO_ENABLED=0 GOOS=windows go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*.exe ./cmd/$* ; \
73-
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*-ppc64le ./cmd/$* ; \
74-
fi
76+
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
77+
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o "./bin/$*$$suffix" ./cmd/$*); then \
78+
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
79+
exit 1; \
80+
fi; \
81+
done
7582

76-
container-%: build-%
83+
$(CMDS:%=container-%): container-%: build-%
7784
docker build -t $*:latest -f $(shell if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV) .
7885

79-
push-%: container-%
86+
$(CMDS:%=push-%): push-%: container-%
8087
set -ex; \
8188
push_image () { \
8289
docker tag $*:latest $(IMAGE_NAME):$$tag; \
@@ -98,6 +105,77 @@ build: $(CMDS:%=build-%)
98105
container: $(CMDS:%=container-%)
99106
push: $(CMDS:%=push-%)
100107

108+
# Additional parameters are needed when pushing to a local registry,
109+
# see https://github.com/docker/buildx/issues/94.
110+
# However, that then runs into https://github.com/docker/cli/issues/2396.
111+
#
112+
# What works for local testing is:
113+
# make push-multiarch PULL_BASE_REF=master REGISTRY_NAME=<your account on dockerhub.io> BUILD_PLATFORMS="linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x"
114+
DOCKER_BUILDX_CREATE_ARGS ?=
115+
116+
# This target builds a multiarch image for one command using Moby BuildKit builder toolkit.
117+
# Docker Buildx is included in Docker 19.03.
118+
#
119+
# ./cmd/<command>/Dockerfile[.Windows] is used if found, otherwise Dockerfile[.Windows].
120+
# It is currently optional: if no such file exists, Windows images are not included,
121+
# even when Windows is listed in BUILD_PLATFORMS. That way, projects can test that
122+
# Windows binaries can be built before adding a Dockerfile for it.
123+
#
124+
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
125+
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
126+
# the tag for the resulting multiarch image.
127+
$(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
128+
set -ex; \
129+
DOCKER_CLI_EXPERIMENTAL=enabled; \
130+
export DOCKER_CLI_EXPERIMENTAL; \
131+
docker buildx create $(DOCKER_BUILDX_CREATE_ARGS) --use --name multiarchimage-buildertest; \
132+
trap "docker buildx rm multiarchimage-buildertest" EXIT; \
133+
dockerfile_linux=$$(if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi); \
134+
dockerfile_windows=$$(if [ -e ./cmd/$*/Dockerfile.Windows ]; then echo ./cmd/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
135+
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
136+
if ! [ -f "$$dockerfile_windows" ]; then \
137+
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe//g' -e 's/; *;/;/g')"; \
138+
fi; \
139+
pushMultiArch () { \
140+
tag=$$1; \
141+
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do \
142+
docker buildx build --push \
143+
--tag $(IMAGE_NAME):$$arch-$$os-$$tag \
144+
--platform=$$os/$$arch \
145+
--file $$(eval echo \$${dockerfile_$$os}) \
146+
--build-arg binary=./bin/$*$$suffix \
147+
--label revision=$(REV) \
148+
.; \
149+
done; \
150+
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do echo $(IMAGE_NAME):$$arch-$$os-$$tag; done); \
151+
docker manifest create --amend $(IMAGE_NAME):$$tag $$images; \
152+
docker manifest push -p $(IMAGE_NAME):$$tag; \
153+
}; \
154+
if [ $(PULL_BASE_REF) = "master" ]; then \
155+
: "creating or overwriting canary image"; \
156+
pushMultiArch canary; \
157+
elif echo $(PULL_BASE_REF) | grep -q -e 'release-*' ; then \
158+
: "creating or overwriting canary image for release branch"; \
159+
release_canary_tag=$$(echo $(PULL_BASE_REF) | cut -f2 -d '-')-canary; \
160+
pushMultiArch $$release_canary_tag; \
161+
elif docker pull $(IMAGE_NAME):$(PULL_BASE_REF) 2>&1 | tee /dev/stderr | grep -q "manifest for $(IMAGE_NAME):$(PULL_BASE_REF) not found"; then \
162+
: "creating release image"; \
163+
pushMultiArch $(PULL_BASE_REF); \
164+
else \
165+
: "ERROR: release image $(IMAGE_NAME):$(PULL_BASE_REF) already exists: a new tag is required!"; \
166+
exit 1; \
167+
fi
168+
169+
.PHONY: check-pull-base-ref
170+
check-pull-base-ref:
171+
if ! [ "$(PULL_BASE_REF)" ]; then \
172+
echo >&2 "ERROR: PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name."; \
173+
exit 1; \
174+
fi
175+
176+
.PHONY: push-multiarch
177+
push-multiarch: $(CMDS:%=push-multiarch-%)
178+
101179
clean:
102180
-rm -rf bin
103181

release-tools/cloudbuild.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. release-tools/prow.sh
5+
6+
gcr_cloud_build

release-tools/cloudbuild.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# A configuration file for multi-arch image building with the Google cloud build service.
2+
#
3+
# Repos using this file must:
4+
# - import csi-release-tools
5+
# - add a symlink cloudbuild.yaml -> release-tools/cloudbuild.yaml
6+
# - add a .cloudbuild.sh which can be a custom file or a symlink
7+
# to release-tools/cloudbuild.sh
8+
# - accept "binary" as build argument in their Dockerfile(s) (see
9+
# https://github.com/pohly/node-driver-registrar/blob/3018101987b0bb6da2a2657de607174d6e3728f7/Dockerfile#L4-L6)
10+
# because binaries will get built for different architectures and then
11+
# get copied from the built host into the container image
12+
#
13+
# See https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
14+
# for more details on image pushing process in Kubernetes.
15+
16+
# This must be specified in seconds. If omitted, defaults to 600s (10 mins).
17+
timeout: 1200s
18+
# This prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF,
19+
# or any new substitutions added in the future.
20+
options:
21+
substitution_option: ALLOW_LOOSE
22+
steps:
23+
# The image must contain bash and curl. Ideally it should also contain
24+
# the desired version of Go (currently defined in release-tools/travis.yml),
25+
# but that just speeds up the build and is not required.
26+
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20200421-a2bf5f8'
27+
entrypoint: ./.cloudbuild.sh
28+
env:
29+
- GIT_TAG=${_GIT_TAG}
30+
- PULL_BASE_REF=${_PULL_BASE_REF}
31+
- REGISTRY_NAME=gcr.io/${_STAGING_PROJECT}
32+
- HOME=/root
33+
substitutions:
34+
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
35+
# can be used as a substitution.
36+
_GIT_TAG: '12345'
37+
# _PULL_BASE_REF will contain the ref that was pushed to trigger this build -
38+
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
39+
_PULL_BASE_REF: 'master'
40+
# The default gcr.io staging project for Kubernetes-CSI
41+
# (=> https://console.cloud.google.com/gcr/images/k8s-staging-csi/GLOBAL).
42+
# Might be overridden in the Prow build job for a repo which wants
43+
# images elsewhere.
44+
_STAGING_PROJECT: 'k8s-staging-csi'

release-tools/prow.sh

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ get_versioned_variable () {
8585
echo "$value"
8686
}
8787

88+
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
89+
8890
# If we have a vendor directory, then use it. We must be careful to only
8991
# use this for "make" invocations inside the project's repo itself because
9092
# setting it globally can break other go usages (like "go get <some command>"
@@ -340,7 +342,7 @@ configvar CSI_PROW_E2E_ALPHA_GATES_LATEST '' "alpha feature gates for latest Kub
340342
configvar CSI_PROW_E2E_ALPHA_GATES "$(get_versioned_variable CSI_PROW_E2E_ALPHA_GATES "${csi_prow_kubernetes_version_suffix}")" "alpha E2E feature gates"
341343

342344
# Which external-snapshotter tag to use for the snapshotter CRD and snapshot-controller deployment
343-
configvar CSI_SNAPSHOTTER_VERSION 'v2.0.0' "external-snapshotter version tag"
345+
configvar CSI_SNAPSHOTTER_VERSION 'v2.0.1' "external-snapshotter version tag"
344346

345347
# Some tests are known to be unusable in a KinD cluster. For example,
346348
# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
@@ -1026,7 +1028,7 @@ main () {
10261028
images=
10271029
if ${CSI_PROW_BUILD_JOB}; then
10281030
# A successful build is required for testing.
1029-
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make all "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}" || die "'make all' failed"
1031+
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make all "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}" "BUILD_PLATFORMS=${CSI_PROW_BUILD_PLATFORMS}" || die "'make all' failed"
10301032
# We don't want test failures to prevent E2E testing below, because the failure
10311033
# might have been minor or unavoidable, for example when experimenting with
10321034
# changes in "release-tools" in a PR (that fails the "is release-tools unmodified"
@@ -1062,18 +1064,24 @@ main () {
10621064
# always pulling the image
10631065
# (https://github.com/kubernetes-sigs/kind/issues/328).
10641066
docker tag "$i:latest" "$i:csiprow" || die "tagging the locally built container image for $i failed"
1065-
done
10661067

1067-
if [ -e deploy/kubernetes/rbac.yaml ]; then
1068-
# This is one of those components which has its own RBAC rules (like external-provisioner).
1069-
# We are testing a locally built image and also want to test with the the current,
1070-
# potentially modified RBAC rules.
1071-
if [ "$(echo "$cmds" | wc -w)" != 1 ]; then
1072-
die "ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds"
1068+
# For components with multiple cmds, the RBAC file should be in the following format:
1069+
# rbac-$cmd.yaml
1070+
# If this file cannot be found, we can default to the standard location:
1071+
# deploy/kubernetes/rbac.yaml
1072+
rbac_file_path=$(find . -type f -name "rbac-$i.yaml")
1073+
if [ "$rbac_file_path" == "" ]; then
1074+
rbac_file_path="$(pwd)/deploy/kubernetes/rbac.yaml"
10731075
fi
1074-
e=$(echo "$cmds" | tr '[:lower:]' '[:upper:]' | tr - _)
1075-
images="$images ${e}_RBAC=$(pwd)/deploy/kubernetes/rbac.yaml"
1076-
fi
1076+
1077+
if [ -e "$rbac_file_path" ]; then
1078+
# This is one of those components which has its own RBAC rules (like external-provisioner).
1079+
# We are testing a locally built image and also want to test with the the current,
1080+
# potentially modified RBAC rules.
1081+
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
1082+
images="$images ${e}_RBAC=$rbac_file_path"
1083+
fi
1084+
done
10771085
fi
10781086

10791087
if tests_need_non_alpha_cluster; then
@@ -1181,3 +1189,17 @@ main () {
11811189

11821190
return "$ret"
11831191
}
1192+
1193+
# This function can be called by a repo's top-level cloudbuild.sh:
1194+
# it handles environment set up in the GCR cloud build and then
1195+
# invokes "make push-multiarch" to do the actual image building.
1196+
gcr_cloud_build () {
1197+
# Register gcloud as a Docker credential helper.
1198+
# Required for "docker buildx build --push".
1199+
gcloud auth configure-docker
1200+
1201+
# Extract tag-n-hash value from GIT_TAG (form vYYYYMMDD-tag-n-hash) for REV value.
1202+
REV=v$(echo "$GIT_TAG" | cut -f3- -d 'v')
1203+
1204+
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make push-multiarch REV="${REV}" REGISTRY_NAME="${REGISTRY_NAME}" BUILD_PLATFORMS="${CSI_PROW_BUILD_PLATFORMS}"
1205+
}

0 commit comments

Comments
 (0)