Skip to content

Commit

Permalink
Align Makefile (release) and hack/tools with other repos (#286)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Augustus <saugustus@vmware.com>
  • Loading branch information
justaugustus committed Oct 2, 2019
1 parent b02098a commit 4ee2261
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 16 deletions.
48 changes: 39 additions & 9 deletions Makefile
Expand Up @@ -58,6 +58,9 @@ CRD_ROOT ?= $(MANIFEST_ROOT)/crd/bases
WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook
RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac

# Allow overriding the imagePullPolicy
PULL_POLICY ?= Always

## --------------------------------------
## Help
## --------------------------------------
Expand All @@ -79,7 +82,8 @@ test-integration: ## Run integration tests

.PHONY: test-e2e
test-e2e: ## Run e2e tests
go test -v -tags=e2e ./test/e2e/...
PULL_POLICY=IfNotPresent $(MAKE) docker-build
go test -v -tags=e2e -timeout=1h ./test/e2e/... -args --managerImage $(CONTROLLER_IMG)-$(ARCH):$(TAG)

## --------------------------------------
## Binaries
Expand Down Expand Up @@ -111,6 +115,8 @@ $(MOCKGEN): $(TOOLS_DIR)/go.mod # Build mockgen from tools folder.
$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen

$(RELEASE_NOTES) : $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags tools -o $(BIN_DIR)/release-notes sigs.k8s.io/cluster-api/hack/tools/release

## --------------------------------------
## Linting
Expand Down Expand Up @@ -174,6 +180,7 @@ generate-examples: clean-examples ## Generate examples configurations to run a c
docker-build: ## Build the docker image for controller-manager
docker build --pull --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG)-$(ARCH):$(TAG)
MANIFEST_IMG=$(CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) $(MAKE) set-manifest-image
$(MAKE) set-manifest-pull-policy

.PHONY: docker-push
docker-push: ## Push the docker image
Expand Down Expand Up @@ -203,12 +210,18 @@ docker-push-manifest: ## Push the fat manifest docker image.
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${TAG} ${CONTROLLER_IMG}-$${arch}:${TAG}; done
docker manifest push --purge ${CONTROLLER_IMG}:${TAG}
MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) $(MAKE) set-manifest-image
$(MAKE) set-manifest-pull-policy

.PHONY: set-manifest-image
set-manifest-image:
$(info Updating kustomize image patch file for manager resource)
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/default/manager_image_patch.yaml

.PHONY: set-manifest-pull-policy
set-manifest-pull-policy:
$(info Updating kustomize pull policy file for manager resource)
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' ./config/default/manager_pull_policy.yaml

## --------------------------------------
## Release
## --------------------------------------
Expand All @@ -228,6 +241,7 @@ release: clean-release ## Builds and push container images using the latest git
# Set the manifest image to the production bucket.
MANIFEST_IMG=$(PROD_REGISTRY)/$(IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG) \
$(MAKE) set-manifest-image
PULL_POLICY=IfNotPresent $(MAKE) set-manifest-pull-policy
$(MAKE) release-manifests

.PHONY: release-manifests
Expand All @@ -249,29 +263,45 @@ release-binary: $(RELEASE_DIR)

.PHONY: release-staging
release-staging: ## Builds and push container images to the staging bucket.
REGISTRY=$(STAGING_REGISTRY) $(MAKE) docker-build-all docker-push-all release-tag-latest
REGISTRY=$(STAGING_REGISTRY) $(MAKE) docker-build-all docker-push-all release-alias-tag

RELEASE_ALIAS_TAG=$(shell if [ "$(PULL_BASE_REF)" = "master" ]; then echo "latest"; else echo "$(PULL_BASE_REF)"; fi)

.PHONY: release-alias-tag
release-alias-tag: # Adds the tag to the last build tag.
gcloud container images add-tag $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)

.PHONY: release-tag-latest
release-tag-latest: ## Adds the latest tag to the last build tag.
## TODO(vincepri): Only do this when we're on master.
gcloud container images add-tag $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):latest
.PHONY: release-notes
release-notes: $(RELEASE_NOTES)
$(RELEASE_NOTES)

## --------------------------------------
## Development
## --------------------------------------

# TODO: Uncomment this once we've enabled image building: https://github.com/kubernetes-sigs/image-builder/pull/49
# Addons (CNI) currently fail to deploy, likely due to a timeout with API server availability.
# Without a pre-built image, capz takes longer for the control plane to come up.
# In the meantime, we'll use a `postKubeadmCommands` in controlplane-0 (examples/controlplane/controlplane.yaml).
# Please also remove that command once we confirm the create-cluster target works again.
.PHONY: create-cluster
create-cluster: $(CLUSTERCTL) ## Create a development Kubernetes cluster on Azure using examples
$(CLUSTERCTL) \
#create-cluster: $(CLUSTERCTL) ## Create a development Kubernetes cluster on Azure using examples
# $(CLUSTERCTL) \
create cluster -v 4 \
--bootstrap-flags="name=clusterapi" \
--bootstrap-type kind \
-m ./examples/_out/controlplane.yaml \
-c ./examples/_out/cluster.yaml \
-p ./examples/_out/provider-components.yaml \
-a ./examples/addons.yaml

create-cluster: $(CLUSTERCTL) ## Create a development Kubernetes cluster on Azure using examples
$(CLUSTERCTL) \
create cluster -v 4 \
--bootstrap-flags="name=clusterapi" \
--bootstrap-type kind \
-m ./examples/_out/controlplane.yaml \
-c ./examples/_out/cluster.yaml \
-p ./examples/_out/provider-components.yaml

.PHONY: create-cluster-management
create-cluster-management: $(CLUSTERCTL) ## Create a development Kubernetes cluster on Azure in a KIND management cluster.
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Expand Up @@ -8,7 +8,7 @@ steps:
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
- TAG=$_GIT_TAG
- ADDITIONAL_TAG=$_PULL_BASE_REF
- PULL_BASE_REF=$_PULL_BASE_REF
args:
- release-staging
substitutions:
Expand Down
3 changes: 2 additions & 1 deletion hack/tools/go.mod
@@ -1,11 +1,12 @@
module sigs.k8s.io/cluster-api/hack/tools
module sigs.k8s.io/cluster-api-provider-azure/hack/tools

go 1.12

require (
github.com/golang/mock v1.3.1
github.com/golangci/golangci-lint v1.19.1
k8s.io/code-generator v0.0.0-20190923155300-6206bfaf5c98
sigs.k8s.io/cluster-api/hack/tools v0.0.0-20191002152509-a6b5ba419bad
sigs.k8s.io/controller-tools v0.2.1
sigs.k8s.io/testing_frameworks v0.1.1
)
Expand Down

1 comment on commit 4ee2261

@Putheach
Copy link

Choose a reason for hiding this comment

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

ok

Please sign in to comment.