-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]: Provider components as artifacts #371
Closed
randomvariable
wants to merge
1
commit into
kubernetes-sigs:master
from
randomvariable:provider-components-artifacts
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,10 @@ | |
FASTBUILD ?= n ## Set FASTBUILD=y (case-sensitive) to skip some slow tasks | ||
|
||
## Image URL to use all building/pushing image targets | ||
STABLE_DOCKER_REPO ?= gcr.io/cluster-api-provider-aws | ||
MANAGER_IMAGE_NAME ?= cluster-api-aws-controller | ||
MANAGER_IMAGE_TAG ?= 0.0.3 | ||
MANAGER_IMAGE ?= $(STABLE_DOCKER_REPO)/$(MANAGER_IMAGE_NAME):$(MANAGER_IMAGE_TAG) | ||
DEV_DOCKER_REPO ?= gcr.io/$(shell gcloud config get-value project) | ||
DEV_MANAGER_IMAGE ?= $(DEV_DOCKER_REPO)/$(MANAGER_IMAGE_NAME):$(MANAGER_IMAGE_TAG) | ||
|
||
REGISTRY_DEV ?= gcr.io/$(shell gcloud config get-value project) | ||
DEPCACHEAGE ?= 24h # Enables caching for Dep | ||
BAZEL_ARGS ?= | ||
BAZEL_DOCKER_ARGS := --define=REGISTRY_DEV=$(REGISTRY_DEV) $(BAZEL_ARGS) | ||
|
||
# Bazel variables | ||
BAZEL_VERSION := $(shell command -v bazel 2> /dev/null) | ||
|
@@ -37,8 +32,11 @@ DEP ?= bazel run dep | |
# determine the OS | ||
HOSTOS := $(shell go env GOHOSTOS) | ||
HOSTARCH := $(shell go env GOARCH) | ||
GOPATH := $(shell go env GOPATH) | ||
BINARYPATHPATTERN :=${HOSTOS}_${HOSTARCH}_* | ||
|
||
export GOPATH | ||
|
||
ifndef BAZEL_VERSION | ||
$(error "Bazel is not available. \ | ||
Installation instructions can be found at \ | ||
|
@@ -70,25 +68,9 @@ gazelle: ## Run Bazel Gazelle | |
check-install: ## Checks that you've installed this repository correctly | ||
@./scripts/check-install.sh | ||
|
||
.PHONY: manager | ||
manager: generate ## Build manager binary. | ||
bazel build //cmd/manager $(BAZEL_ARGS) | ||
install bazel-bin/cmd/manager/${BINARYPATHPATTERN}/manager $(shell go env GOPATH)/bin/aws-manager | ||
|
||
.PHONY: clusterctl | ||
clusterctl: generate ## Build clusterctl binary. | ||
bazel build --workspace_status_command=./hack/print-workspace-status.sh //cmd/clusterctl $(BAZEL_ARGS) | ||
install bazel-bin/cmd/clusterctl/${BINARYPATHPATTERN}/clusterctl $(shell go env GOPATH)/bin/clusterctl | ||
|
||
.PHONY: clusterawsadm | ||
clusterawsadm: dep-ensure ## Build clusterawsadm binary. | ||
bazel build --workspace_status_command=./hack/print-workspace-status.sh //cmd/clusterawsadm $(BAZEL_ARGS) | ||
install bazel-bin/cmd/clusterawsadm/${BINARYPATHPATTERN}/clusterawsadm $(shell go env GOPATH)/bin/clusterawsadm | ||
|
||
.PHONY: release-binaries | ||
release-binaries: ## Build release binaries | ||
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //cmd/clusterctl //cmd/clusterawsadm | ||
bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //cmd/clusterctl //cmd/clusterawsadm | ||
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64,@io_bazel_rules_go//go/toolchain:darwin_amd64 --build_tag_filters=cli //... | ||
mkdir -p out | ||
install bazel-bin/cmd/clusterawsadm/darwin_amd64_pure_stripped/clusterawsadm out/clusterawsadm-darwin-amd64 | ||
install bazel-bin/cmd/clusterawsadm/linux_amd64_pure_stripped/clusterawsadm out/clusterawsadm-linux-amd64 | ||
|
@@ -97,34 +79,27 @@ release-binaries: ## Build release binaries | |
|
||
.PHONY: test verify | ||
test: generate verify ## Run tests | ||
bazel test --nosandbox_debug //pkg/... //cmd/... $(BAZEL_ARGS) | ||
bazel test //pkg/... //cmd/... $(BAZEL_ARGS) | ||
|
||
verify: | ||
./hack/verify_boilerplate.py | ||
|
||
.PHONY: copy-genmocks | ||
copy-genmocks: ## Copies generated mocks into the repository | ||
cp -Rf bazel-genfiles/pkg/* pkg/ | ||
|
||
BAZEL_DOCKER_ARGS_COMMON := --define=MANAGER_IMAGE_NAME=$(MANAGER_IMAGE_NAME) --define=MANAGER_IMAGE_TAG=$(MANAGER_IMAGE_TAG) $(BAZEL_ARGS) | ||
BAZEL_DOCKER_ARGS := --define=DOCKER_REPO=$(STABLE_DOCKER_REPO) $(BAZEL_DOCKER_ARGS_COMMON) | ||
BAZEL_DOCKER_ARGS_DEV := --define=DOCKER_REPO=$(DEV_DOCKER_REPO) $(BAZEL_DOCKER_ARGS_COMMON) | ||
|
||
.PHONY: docker-build | ||
docker-build: generate ## Build the production docker image | ||
docker-build: generate provider-components ## Build the production docker image | ||
bazel run //cmd/manager:manager-image $(BAZEL_DOCKER_ARGS) | ||
|
||
.PHONY: docker-build-dev | ||
docker-build-dev: generate ## Build the development docker image | ||
bazel run //cmd/manager:manager-image $(BAZEL_DOCKER_ARGS_DEV) | ||
|
||
.PHONY: docker-push | ||
docker-push: generate ## Push production docker image | ||
docker-push: generate provider-components ## Push production docker image | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I missing the provider-components target? I only see provider-components-dev added |
||
bazel run //cmd/manager:manager-push $(BAZEL_DOCKER_ARGS) | ||
|
||
.PHONY: docker-push-dev | ||
docker-push-dev: generate ## Push development image | ||
bazel run //cmd/manager:manager-push $(BAZEL_DOCKER_ARGS_DEV) | ||
docker-push-dev: generate provider-components-dev ## Push development image | ||
bazel run //cmd/manager:manager-push-dev $(BAZEL_DOCKER_ARGS) | ||
|
||
.PHONY: provider-components-dev | ||
provider-components-dev: provider-components ## Generate Kustomize version patch for the Docker image | ||
bazel build //cmd/manager:manager-version-patch-dev $(BAZEL_DOCKER_ARGS) | ||
install bazel-genfiles/cmd/manager/manager-version-patch-dev.yaml cmd/manager | ||
|
||
.PHONY: clean | ||
clean: ## Remove all generated files | ||
|
@@ -138,68 +113,32 @@ clean: ## Remove all generated files | |
reset-bazel: ## Deep cleaning for bazel | ||
bazel clean --expunge | ||
|
||
cmd/clusterctl/examples/aws/out: | ||
./cmd/clusterctl/examples/aws/generate-yaml.sh | ||
|
||
cmd/clusterctl/examples/aws/out/credentials: cmd/clusterctl/examples/aws/out ## Generate k8s secret for AWS credentials | ||
clusterawsadm alpha bootstrap generate-aws-default-profile > cmd/clusterctl/examples/aws/out/credentials | ||
|
||
.PHONY: examples | ||
examples: ## Generate example output | ||
$(MAKE) cmd/clusterctl/examples/aws/out MANAGER_IMAGE=${MANAGER_IMAGE} | ||
|
||
.PHONY: examples-dev | ||
examples-dev: ## Generate example output with developer image | ||
$(MAKE) cmd/clusterctl/examples/aws/out MANAGER_IMAGE=${DEV_MANAGER_IMAGE} | ||
|
||
.PHONY: manifests | ||
manifests: cmd/clusterctl/examples/aws/out/credentials ## Generate manifests for clusterctl | ||
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd | ||
kustomize build config/default/ > cmd/clusterctl/examples/aws/out/provider-components.yaml | ||
echo "---" >> cmd/clusterctl/examples/aws/out/provider-components.yaml | ||
kustomize build vendor/sigs.k8s.io/cluster-api/config/default/ >> cmd/clusterctl/examples/aws/out/provider-components.yaml | ||
|
||
.PHONY: manifests-dev | ||
manifests-dev: dep-ensure dep-install binaries-dev ## Builds development manifests | ||
MANAGER_IMAGE=$(DEV_MANAGER_IMAGE) MANAGER_IMAGE_PULL_POLICY="Always" $(MAKE) manifests | ||
|
||
# TODO(vincepri): This should move to rebuild Bazel binaries once every | ||
# make target uses Bazel bins to run operations. | ||
.PHONY: binaries-dev | ||
binaries-dev: ## Builds and installs the binaries on the local GOPATH | ||
go get -v ./... | ||
go install -v ./... | ||
|
||
.PHONY: create-cluster | ||
create-cluster: ## Create a Kubernetes cluster on AWS using examples | ||
clusterctl create cluster -v 3 \ | ||
--provider aws \ | ||
--bootstrap-type kind \ | ||
-m ./cmd/clusterctl/examples/aws/out/machines.yaml \ | ||
-c ./cmd/clusterctl/examples/aws/out/cluster.yaml \ | ||
-p ./cmd/clusterctl/examples/aws/out/provider-components.yaml \ | ||
-a ./cmd/clusterctl/examples/aws/out/addons.yaml | ||
.PHONY: cli-dev | ||
cli-dev: ## Builds and installs the binaries on the local GOPATH | ||
bazel build --build_tag_filters=cli //... $(BAZEL_ARGS) | ||
install bazel-bin/cmd/clusterawsadm/${BINARYPATHPATTERN}/clusterawsadm $(GOPATH)/bin/clusterawsadm | ||
install bazel-bin/cmd/clusterctl/${BINARYPATHPATTERN}/clusterctl $(GOPATH)/bin/clusterctl | ||
|
||
|
||
.PHONY: lint-full | ||
lint-full: dep-ensure ## Run slower linters to detect possible issues | ||
bazel run //:lint-full $(BAZEL_ARGS) | ||
|
||
## Define kind dependencies here. | ||
|
||
kind-reset: ## Destroys the "clusterapi" kind cluster. | ||
kind delete cluster --name=clusterapi || true | ||
bazel run //:kind-reset $(BAZEL_ARGS) | ||
|
||
.PHONY: config | ||
config: ## Create Kubernetes API components | ||
bazel build //config | ||
cp -Rf bazel-genfiles/config/* config/ | ||
|
||
ifneq ($(FASTBUILD),y) | ||
|
||
## Define slow dependency targets here | ||
|
||
.PHONY: generate | ||
generate: gazelle dep-ensure ## Run go generate | ||
GOPATH=$(shell go env GOPATH) bazel run //:generate $(BAZEL_ARGS) | ||
$(MAKE) dep-ensure | ||
bazel build $(BAZEL_ARGS) //pkg/cloud/aws/services/mocks:go_mock_interfaces \ | ||
//pkg/cloud/aws/services/ec2/mock_ec2iface:go_default_library \ | ||
//pkg/cloud/aws/services/elb/mock_elbiface:go_default_library | ||
cp -Rf bazel-genfiles/pkg/* pkg/ | ||
bazel build --build_tag_filters=generated //... $(BAZEL_ARGS) | ||
|
||
.PHONY: lint | ||
lint: dep-ensure ## Lint codebase | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exports_files([ | ||
"stateful_set_patch.yaml", | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This is a modified version of the same rule from kubernetes/repo-infra | ||
# modified to add the GO SDK to the PATH environment variable. | ||
|
||
# Writes out a script which saves the runfiles directory, | ||
# changes to the workspace root, and then runs a command. | ||
|
||
def add_file(in_file, output, path = None): | ||
output_path = output | ||
input_path = in_file.path | ||
|
||
if path and in_file.short_path.startswith(path): | ||
output_path += in_file.short_path[len(path):] | ||
|
||
return [ | ||
"mkdir -p $(dirname %s)" % output_path, | ||
"test -L %s || ln -s $(pwd)/%s %s" % (output_path, input_path, output_path), | ||
] | ||
|
||
def add_files(in_files, path = None): | ||
cmds = [add_file(in_file, in_file.path.build_output, path) for in_file in in_files] | ||
return cmds.join(" && ") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add a comment stating that these variables can be overridden?