Skip to content

Commit faf6a1b

Browse files
authored
Merge pull request #67 from alexander-demicev/release-tasks
✨Add release make tasks
2 parents ffb3a51 + 64ebf3c commit faf6a1b

File tree

5 files changed

+40
-51
lines changed

5 files changed

+40
-51
lines changed

Makefile

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ GINKGO := $(abspath $(TOOLS_BIN_DIR)/ginkgo)
6262
ENVSUBST := $(abspath $(TOOLS_BIN_DIR)/envsubst)
6363

6464
# Define Docker related variables. Releases should modify and double check these vars.
65-
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
66-
PROD_REGISTRY ?= registry.k8s.io/cluster-api
65+
STAGING_REGISTRY ?= gcr.io/k8s-staging-capi-operator
66+
STAGING_BUCKET ?= artifacts.k8s-staging-capi-operator.appspot.com
6767

68-
STAGING_REGISTRY ?= gcr.io/k8s-staging-cluster-api
69-
STAGING_BUCKET ?= artifacts.k8s-staging-cluster-api.appspot.com
68+
REGISTRY ?= $(STAGING_REGISTRY)
69+
PROD_REGISTRY ?= registry.k8s.io/capi-operator
7070

7171
# Image name
7272
IMAGE_NAME ?= cluster-api-operator
7373
CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME)
74+
CONTROLLER_IMG_TAG ?= $(CONTROLLER_IMG)-$(ARCH):$(TAG)
7475

7576
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
7677
TAG ?= dev
@@ -243,18 +244,21 @@ modules: ## Runs go mod to ensure modules are up to date.
243244
.PHONY: docker-pull-prerequisites
244245
docker-pull-prerequisites:
245246
docker pull docker.io/docker/dockerfile:1.1-experimental
246-
docker pull docker.io/library/golang:1.17.0
247+
docker pull docker.io/library/golang:1.19.0
247248
docker pull gcr.io/distroless/static:latest
248249

249250
.PHONY: docker-build
250-
docker-build: ## Build the docker image for management cluster operator
251-
DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG)-$(ARCH):$(TAG)
252-
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
253-
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
251+
docker-build: docker-pull-prerequisites ## Build the docker image for controller-manager
252+
docker build --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CONTROLLER_IMG_TAG)
254253

255254
.PHONY: docker-push
256255
docker-push: ## Push the docker image
257-
docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG)
256+
docker push $(CONTROLLER_IMG_TAG)
257+
258+
.PHONY: staging-manifests
259+
staging-manifests:
260+
$(MAKE) manifest-modification PULL_POLICY=IfNotPresent RELEASE_TAG=$(RELEASE_ALIAS_TAG)
261+
$(MAKE) release-manifests
258262

259263
## --------------------------------------
260264
## Docker — All ARCH
@@ -273,14 +277,9 @@ docker-push-all: $(addprefix docker-push-,$(ALL_ARCH))
273277
docker-push-%:
274278
$(MAKE) ARCH=$* docker-push
275279

276-
.PHONY: docker-push
277-
docker-push-operator: ## Push the fat manifest docker image for the operator image.
278-
## Minimum docker version 18.06.0 is required for creating and pushing manifest images.
279-
docker manifest create --amend $(CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLLER_IMG)\-&:$(TAG)~g")
280-
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${TAG} ${CONTROLLER_IMG}-$${arch}:${TAG}; done
281-
docker manifest push --purge $(CONTROLLER_IMG):$(TAG)
282-
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
283-
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
280+
.PHONY: docker-build-e2e
281+
docker-build-e2e:
282+
$(MAKE) CONTROLLER_IMG_TAG="gcr.io/k8s-staging-capi-operator/cluster-api-operator:dev" docker-build
284283

285284
.PHONY: set-manifest-pull-policy
286285
set-manifest-pull-policy:
@@ -300,43 +299,40 @@ $(RELEASE_DIR):
300299
mkdir -p $(RELEASE_DIR)/
301300

302301
.PHONY: release
303-
release: clean-release ## Builds and push container images using the latest git tag for the commit.
302+
release: clean-release $(RELEASE_DIR) ## Builds and push container images using the latest git tag for the commit.
304303
@if [ -z "${RELEASE_TAG}" ]; then echo "RELEASE_TAG is not set"; exit 1; fi
305304
@if ! [ -z "$$(git status --porcelain)" ]; then echo "Your local git repository contains uncommitted changes, use git clean before proceeding."; exit 1; fi
306305
git checkout "${RELEASE_TAG}"
307-
# Set the manifest image to the staging bucket.
308-
REGISTRY=$(STAGING_REGISTRY) $(MAKE) manifest-modification
306+
# Set the manifest image to the production bucket.
307+
$(MAKE) manifest-modification REGISTRY=$(PROD_REGISTRY)
309308
$(MAKE) release-manifests
310309

311310
.PHONY: manifest-modification
312311
manifest-modification: # Set the manifest images to the staging/production bucket.
313312
$(MAKE) set-manifest-image \
314-
MANIFEST_IMG=$(PROD_REGISTRY)/$(OPERATOR_IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG) \
315-
TARGET_RESOURCE="./exp/operator/config/default/manager_image_patch.yaml"
313+
MANIFEST_IMG=$(REGISTRY)/$(IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG) \
314+
TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
316315
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
317316

318317
.PHONY: release-manifests
319318
release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a release
320319
$(KUSTOMIZE) build ./config/default > $(RELEASE_DIR)/operator-components.yaml
321320

322321
.PHONY: release-staging
323-
release-staging: ## Builds and push container images to the staging bucket.
324-
REGISTRY=$(STAGING_REGISTRY) $(MAKE) docker-build-all docker-push-all release-alias-tag
325-
326-
.PHONY: release-staging-nightly
327-
release-staging-nightly: ## Tags and push container images to the staging bucket. Example image tag: cluster-api-controller:nightly_master_20210121
328-
$(eval NEW_RELEASE_ALIAS_TAG := nightly_$(RELEASE_ALIAS_TAG)_$(shell date +'%Y%m%d'))
329-
$(MAKE) release-alias-tag TAG=$(RELEASE_ALIAS_TAG) RELEASE_ALIAS_TAG=$(NEW_RELEASE_ALIAS_TAG)
330-
# Set the manifest image to the production bucket.
331-
$(MAKE) manifest-modification REGISTRY=$(STAGING_REGISTRY) RELEASE_TAG=$(NEW_RELEASE_ALIAS_TAG)
332-
## Build the manifests
333-
$(MAKE) release-manifests
334-
# Example manifest location: artifacts.k8s-staging-cluster-api.appspot.com/components/nightly_master_20210121/infrastructure-components.yaml
335-
gsutil cp $(RELEASE_DIR)/* gs://$(STAGING_BUCKET)/components/$(NEW_RELEASE_ALIAS_TAG)
322+
release-staging: ## Builds and push container images and manifests to the staging bucket.
323+
$(MAKE) docker-build-all
324+
$(MAKE) docker-push-all
325+
$(MAKE) release-alias-tag
326+
$(MAKE) staging-manifests
327+
$(MAKE) upload-staging-artifacts
336328

337329
.PHONY: release-alias-tag
338330
release-alias-tag: # Adds the tag to the last build tag.
339-
gcloud container images add-tag $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
331+
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
332+
333+
.PHONY: upload-staging-artifacts
334+
upload-staging-artifacts: ## Upload release artifacts to the staging bucket
335+
gsutil cp $(RELEASE_DIR)/* gs://$(STAGING_BUCKET)/components/$(RELEASE_ALIAS_TAG)/
340336

341337
## --------------------------------------
342338
## Cleanup / Verification

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load('ext://cert_manager', 'deploy_cert_manager')
44

55
def build_image():
66
docker_build(
7-
"gcr.io/k8s-staging-cluster-api/cluster-api-operator-amd64",
7+
"gcr.io/k8s-staging-capi-operator/cluster-api-operator",
88
".",
99
ignore=[
1010
".git",

cloudbuild.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
21
# See https://cloud.google.com/cloud-build/docs/build-config
32
timeout: 1200s
43
options:
54
substitution_option: ALLOW_LOOSE
65
steps:
7-
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20211013-1be7868d8b'
6+
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20220609-2e4c91eb7e'
87
entrypoint: make
98
env:
109
- DOCKER_CLI_EXPERIMENTAL=enabled
1110
- TAG=$_GIT_TAG
1211
- PULL_BASE_REF=$_PULL_BASE_REF
12+
- DOCKER_BUILDKIT=1
1313
args:
1414
- release-staging
1515
substitutions:

config/default/manager_image_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
template:
88
spec:
99
containers:
10-
- image: gcr.io/k8s-staging-cluster-api/cluster-api-operator-amd64:dev
10+
- image: gcr.io/k8s-staging-capi-operator/cluster-api-operator:dev
1111
name: manager

scripts/ci-e2e.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,12 @@ source "${REPO_ROOT}/hack/ensure-kustomize.sh"
2929
# shellcheck source=./hack/ensure-kind.sh
3030
source "${REPO_ROOT}/hack/ensure-kind.sh"
3131

32-
3332
# Build operator images
34-
ARCH="$(go env GOARCH)"
35-
export REGISTRY=gcr.io/k8s-staging-cluster-api
36-
export IMAGE_NAME=cluster-api-operator
37-
export TAG=dev
38-
export ARCH
39-
export PULL_POLICY=IfNotPresent
40-
export OPERATOR_IMAGE=$REGISTRY/$IMAGE_NAME-$ARCH:$TAG
41-
4233
export CERT_MANAGER_VERSION=v1.7.1
34+
export OPERATOR_IMAGE=gcr.io/k8s-staging-capi-operator/cluster-api-operator:dev
35+
4336
echo "+ Building CAPI operator image"
44-
make docker-build
37+
make docker-build-e2e
4538

4639
echo "+ Running e2e tests"
4740
make test-e2e

0 commit comments

Comments
 (0)