Skip to content

Commit 5fe6b8d

Browse files
committed
feat(release): update image promotion to use kpromo
The release process has been updated to use `kpromo` for handling the image promotion instead of the manual process we had. Signed-off-by: Richard Case <[email protected]>
1 parent 580df83 commit 5fe6b8d

File tree

8 files changed

+99
-23
lines changed

8 files changed

+99
-23
lines changed

Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ARTIFACTS ?= $(REPO_ROOT)/_artifacts
2424
TOOLS_DIR := hack/tools
2525
TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile
2626
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
27-
GO_INSTALL := ./scripts/go_install.sh
27+
2828

2929
API_DIRS := cmd/clusterawsadm/api api exp/api controlplane/eks/api bootstrap/eks/api iam/api
3030
API_FILES := $(foreach dir, $(API_DIRS), $(call rwildcard,../../$(dir),*.go))
@@ -59,6 +59,8 @@ KIND := $(TOOLS_BIN_DIR)/kind
5959
KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
6060
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
6161
SSM_PLUGIN := $(TOOLS_BIN_DIR)/session-manager-plugin
62+
YQ := $(TOOLS_BIN_DIR)/yq
63+
KPROMO := $(TOOLS_BIN_DIR)/kpromo
6264
CLUSTERAWSADM_SRCS := $(call rwildcard,.,cmd/clusterawsadm/*.*)
6365

6466
PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
@@ -74,6 +76,12 @@ else
7476
export GOPATH := $(shell go env GOPATH)
7577
endif
7678

79+
USER_FORK ?= $(shell git config --get remote.origin.url | cut -d/ -f4) # only works on https://github.com/<username>/cluster-api.git style URLs
80+
ifeq ($(USER_FORK),)
81+
USER_FORK := $(shell git config --get remote.origin.url | cut -d: -f2 | cut -d/ -f1) # for [email protected]:<username>/cluster-api.git style URLs
82+
endif
83+
IMAGE_REVIEWERS ?= $(shell ./hack/get-project-maintainers.sh ${YQ})
84+
7785
# Release variables
7886

7987
STAGING_REGISTRY ?= gcr.io/k8s-staging-cluster-api-aws
@@ -569,6 +577,10 @@ release-manifests: ## Release manifest files
569577
release-changelog: $(GH) ## Generates release notes using Github release notes.
570578
./hack/releasechangelog.sh -v $(VERSION) -p $(PREVIOUS_VERSION) -o $(GH_ORG_NAME) -r $(GH_REPO_NAME) -c $(CORE_CONTROLLER_PROMOTED_IMG) > $(RELEASE_DIR)/CHANGELOG.md
571579

580+
.PHONY: promote-images
581+
promote-images: $(KPROMO) $(YQ)
582+
$(KPROMO) pr --project cluster-api-provider-aws --tag $(RELEASE_TAG) --reviewers "$(IMAGE_REVIEWERS)" --fork $(USER_FORK) --image cluster-api-aws-controller
583+
572584
.PHONY: release-binaries
573585
release-binaries: ## Builds the binaries to publish with a release
574586
RELEASE_BINARY=./cmd/clusterawsadm GOOS=linux GOARCH=amd64 $(MAKE) release-binary

common.mk

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
2828
UID := $(shell id -u)
2929
GID := $(shell id -g)
3030

31+
GO_INSTALL := $(ROOT_DIR_RELATIVE)/scripts/go_install.sh
32+
3133
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
3234

3335
# Hosts running SELinux need :z added to volume mounts
-9.87 KB
Binary file not shown.

docs/book/src/development/releasing.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,34 @@
2121

2222
## Promote container images from staging to production
2323

24-
Promote the container images by following the steps below. (For background information, see [this](https://github.com/kubernetes/k8s.io/tree/main/k8s.gcr.io#image-promoter).)
24+
Promote the container images from the staging registry to the production registry (`registry.k8s.io/cluster-api-provider-aws`) by following the steps below.
2525

26-
1. Navigate to the the staging repository [dashboard](https://console.cloud.google.com/gcr/images/k8s-staging-cluster-api-aws/GLOBAL).
27-
1. Choose the _top level_ [cluster-api-aws-controller](https://console.cloud.google.com/gcr/images/k8s-staging-cluster-api-aws/GLOBAL/cluster-api-aws-controller?gcrImageListsize=30) image. Only the top level image provides the multi-arch manifest, rather than one for a specific architecture.
28-
1. Wait for an image to appear with the tagged release version:
29-
![image promotion](./imagepromo1.png)
30-
1. Click on the `Copy full image name` icon.
31-
1. Create your own fork of `kubernetes/k8s.io` in GitHub.
32-
1. Clone and pull down the latest from [kubernetes/k8s.io](https://github.com/kubernetes/k8s.io).
33-
1. Create a new branch in your fork of `kubernetes/k8s.io`.
34-
1. In your `kubernetes/k8s.io` branch edit `k8s.gcr.io/images/k8s-staging-cluster-api-aws/images.yaml` and add an try for the version using the pasted value from earlier. For example: `"sha256:06ce7b97f9fe116df65c293deef63981dec3e33dec9984b8a6dd0f7dba21bb32": ["v0.6.4"]`
35-
1. Create a PR with your change, following [this PR](https://github.com/kubernetes/k8s.io/pull/1565) as example.
36-
1. Wait for the PR to be approved (typically by CAPA maintainers authorized to merge PRs into the k8s.io repository) and merged.
26+
1. Navigate to the the staging repository [dashboard](https://console.cloud.google.com/gcr/images/k8s-staging-cluster-api-aws/GLOBAL).
27+
2. Choose the _top level_ [cluster-api-aws-controller](https://console.cloud.google.com/gcr/images/k8s-staging-cluster-api-aws/GLOBAL/cluster-api-aws-controller?gcrImageListsize=30) image. Only the top level image provides the multi-arch manifest, rather than one for a specific architecture.
28+
3. Wait for an image to appear with the tagged release version.
29+
4. If you don't have a GitHub token, create one by going to your GitHub settings, in [Personal access tokens](https://github.com/settings/tokens). Make sure you give the token the `repo` scope.
30+
5. Create a PR to promote the images:
31+
```bash
32+
export GITHUB_TOKEN=<your GH token>
33+
make promote-images
34+
```
35+
**Notes**:
36+
* `kpromo` uses `[email protected]:...` as remote to push the branch for the PR. If you don't have `ssh` set up you can configure
37+
git to use `https` instead via `git config --global url."https://github.com/".insteadOf [email protected]:`.
38+
* This will automatically create a PR in [k8s.io](https://github.com/kubernetes/k8s.io) and assign the CAPA maintainers.
39+
6. Wait for the PR to be approved (typically by CAPA maintainers authorized to merge PRs into the k8s.io repository) and merged.
40+
7. Verify the images are available in the production registry:
41+
```bash
42+
docker pull registry.k8s.io/cluster-api-provider-aws/cluster-api-aws-controller:${RELEASE_TAG}
43+
```
3744
3845
## Create release artifacts, and a GitHub draft release
3946
40-
1. Again, make sure your repo is clean by git standards.
41-
1. Export the current branch `export BRANCH=release-1.5` (`export BRANCH=main`)and run `make release`.
42-
1. Run `make create-gh-release` to create a draft release on Github, copying the generated release notes from `out/CHANGELOG.md` into the draft.
43-
1. Run `make upload-gh-artifacts` to upload artifacts from .out/ directory. You may run into API limit errors, so verify artifacts at next step.
44-
1. Verify that all the files below are attached to the drafted release:
47+
1. Again, make sure your repo is clean by git standards.
48+
1. Export the current branch `export BRANCH=release-1.5` (`export BRANCH=main`)and run `make release`.
49+
1. Run `make create-gh-release` to create a draft release on Github, copying the generated release notes from `out/CHANGELOG.md` into the draft.
50+
1. Run `make upload-gh-artifacts` to upload artifacts from .out/ directory. You may run into API limit errors, so verify artifacts at next step.
51+
1. Verify that all the files below are attached to the drafted release:
4552
1. `clusterawsadm-darwin-amd64`
4653
1. `clusterawsadm-linux-amd64`
4754
1. `infrastructure-components.yaml`
@@ -54,11 +61,11 @@ Promote the container images by following the steps below. (For background infor
5461
1. `eks-controlplane-components.yaml`
5562
1. `eks-bootstrap-components.yaml`
5663
1. `metadata.yaml`
57-
1. Finalise the release notes by editing the draft release.
64+
1. Finalise the release notes by editing the draft release.
5865
5966
## Publish the draft release
6067
61-
1. Make sure image promotion is complete before publishing the release draft. The promotion job logs can be found [here](https://testgrid.k8s.io/sig-k8s-infra-k8sio#post-k8sio-image-promo) and you can also try and pull the images (i.e. ``docker pull registry.k8s.io/cluster-api-aws/cluster-api-aws-controller:v0.6.4`).
62-
1. Publish release. Use the pre-release option for release
68+
1. Make sure image promotion is complete before publishing the release draft. The promotion job logs can be found [here](https://testgrid.k8s.io/sig-k8s-infra-k8sio#post-k8sio-image-promo) and you can also try and pull the images (i.e. ``docker pull registry.k8s.io/cluster-api-aws/cluster-api-aws-controller:v0.6.4`).
69+
1. Publish release. Use the pre-release option for release
6370
candidate versions of Cluster API Provider AWS.
64-
1. Email `[email protected]` to announce the release.
71+
1. Email `[email protected]` to announce the release.

hack/get-project-maintainers.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
25+
if [ -z "${1}" ]; then
26+
echo "must provide path to yq as first parameter"
27+
exit 1
28+
fi
29+
30+
KEYS=()
31+
while IFS='' read -r line; do KEYS+=("$line"); done < <(${1} e '.aliases["cluster-api-aws-maintainers"][]' OWNERS_ALIASES)
32+
echo "${KEYS[@]/#/@}"

hack/tools/Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ UNAME := $(shell uname -s)
1919

2020
# Directories.
2121
BIN_DIR := bin
22+
BIN_DIR_ABS := $(abspath $(BIN_DIR))
2223
SHARE_DIR := share
2324

2425
OS := $(shell go env GOOS)
@@ -154,6 +155,26 @@ $(PLANTUML): plantuml.Dockerfile ../../versions.mk
154155
docker build --build-arg PLANTUML_VERSION=$(PLANTUML_VERSION) . -f plantuml.Dockerfile -t "plantuml-builder"
155156
touch $@
156157

158+
KPROMO_BIN := kpromo
159+
KPROMO := $(abspath $(BIN_DIR)/$(KPROMO_BIN)-$(KPROMO_VER))
160+
KPROMO_PKG := sigs.k8s.io/promo-tools/v3/cmd/kpromo
161+
162+
.PHONY: $(KPROMO_BIN)
163+
$(KPROMO_BIN): $(KPROMO) ## Build a local copy of kpromo
164+
165+
$(KPROMO):
166+
GOBIN=$(BIN_DIR_ABS) $(GO_INSTALL) $(KPROMO_PKG) $(KPROMO_BIN) ${KPROMO_VERSION}
167+
168+
YQ_BIN := yq
169+
YQ := $(abspath $(BIN_DIR)/$(YQ_BIN)-$(YQ_VERSION))
170+
YQ_PKG := github.com/mikefarah/yq/v4
171+
172+
.PHONY: $(YQ_BIN)
173+
$(YQ_BIN): $(YQ) ## Build a local copy of yq
174+
175+
$(YQ):
176+
GOBIN=$(BIN_DIR_ABS) $(GO_INSTALL) $(YQ_PKG) $(YQ_BIN) ${YQ_VERSION}
177+
157178
## ------------------------------------------------------------------------------------------------
158179
## AWS Session Manager Plugin Installation. Currently support Linux and MacOS AMD64 architectures.
159180
## ------------------------------------------------------------------------------------------------

scripts/go_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ fi
4040
rm "${GOBIN}/${2}"* || true
4141

4242
# install the golang module specified as the first argument
43-
go install -tags tools "${1}@${3}"
43+
go install "${1}@${3}"
4444
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}"
4545
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"

versions.mk

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ PLANTUML_VERSION := 1.2020.16
1717
GH_VERSION := 2.7.0
1818
CERT_MANAGER_VERSION := v1.10.1
1919
CAPI_VERSION := v1.3.5
20+
KPROMO_VERSION := v3.5.1
21+
YQ_VERSION := v4.25.2

0 commit comments

Comments
 (0)