Skip to content

Commit

Permalink
Build release tarballs in bazel and add make bazel-release rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ixdy committed Jan 14, 2017
1 parent 14dd0d3 commit bc4b6ac
Show file tree
Hide file tree
Showing 17 changed files with 521 additions and 26 deletions.
10 changes: 0 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,3 @@ filegroup(
],
tags = ["automanaged"],
)

pkg_tar(
name = "kubernetes-src",
extension = "tar.gz",
files = [
":all-srcs",
],
package_dir = "kubernetes",
strip_prefix = "//",
)
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ help:
endif

# Non-dockerized bazel rules.
.PHONY: bazel-build bazel-test
.PHONY: bazel-build bazel-test bazel-release

ifeq ($(PRINT_HELP),y)
define BAZEL_BUILD_HELP_INFO
Expand Down Expand Up @@ -500,3 +500,17 @@ else
bazel-test:
bazel test --test_output=errors //cmd/... //pkg/... //federation/... //plugin/... //build/... //third_party/... //hack/...
endif

ifeq ($(PRINT_HELP),y)
define BAZEL_BUILD_HELP_INFO
# Build release tars with bazel
#
# Example:
# make bazel-release
endef
bazel-release:
@echo "$$BAZEL_BUILD_HELP_INFO"
else
bazel-release:
bazel build //build/release-tars
endif
244 changes: 244 additions & 0 deletions build/release-tars/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
package(default_visibility = ["//visibility:public"])

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

pkg_tar(
name = "kubernetes-src",
extension = "tar.gz",
files = [
"//:all-srcs",
],
package_dir = "kubernetes",
strip_prefix = "//",
)

# FIXME: this should be configurable/auto-detected
PLATFORM_ARCH_STRING = "linux-amd64"

# KUBE_CLIENT_TARGETS
CLIENT_TARGETS = [
"//cmd/kubectl",
"//federation/cmd/kubefed",
]

# KUBE_NODE_TARGETS
NODE_TARGETS = [
"//cmd/kube-proxy",
"//cmd/kubelet",
]

# KUBE_SERVER_TARGETS
# No need to duplicate CLIENT_TARGETS or NODE_TARGETS here,
# since we include them in the actual build rule.
SERVER_TARGETS = [
"//cmd/hyperkube",
"//cmd/kube-aggregator",
"//cmd/kube-apiserver",
"//cmd/kube-controller-manager",
"//cmd/kube-discovery",
"//cmd/kubeadm",
"//plugin/cmd/kube-scheduler",
]

# kube::golang::test_targets
TEST_BINARY_TARGETS = [
"//cmd/gendocs",
"//cmd/genkubedocs",
"//cmd/genman",
"//cmd/genswaggertypedocs",
"//cmd/genyaml",
"//cmd/linkcheck",
"//cmd/mungedocs",
"//examples/k8petstore/web-server/src",
"//federation/cmd/genfeddocs",
"//test/e2e:e2e.test",
"//vendor:github.com/onsi/ginkgo/ginkgo_bin",
"//cmd/kubemark", # TODO: server platforms only
"//test/e2e_node:e2e_node.test", # TODO: server platforms only
]

TEST_PORTABLE_TARGETS = [
"//federation/develop:all-srcs",
"//hack:e2e.go",
"//hack:federated-ginkgo-e2e.sh",
"//hack:get-build.sh",
"//hack:ginkgo-e2e.sh",
"//hack/e2e-internal:all-srcs",
"//hack/lib:all-srcs",
"//test/e2e/testing-manifests:all-srcs",
"//test/kubemark:all-srcs",
]

# Included in node and server tarballs.
LICENSE_TARGETS = [
"//:Godeps/LICENSES",
":kubernetes-src.tar.gz",
]

pkg_tar(
name = "_client-bin",
files = CLIENT_TARGETS,
mode = "0755",
package_dir = "client/bin",
visibility = ["//visibility:private"],
)

pkg_tar(
name = "kubernetes-client-%s" % PLATFORM_ARCH_STRING,
extension = "tar.gz",
package_dir = "kubernetes",
deps = [
":_client-bin",
],
)

pkg_tar(
name = "_node-bin",
files = NODE_TARGETS + CLIENT_TARGETS,
mode = "0755",
package_dir = "node/bin",
visibility = ["//visibility:private"],
)

pkg_tar(
name = "kubernetes-node-%s" % PLATFORM_ARCH_STRING,
extension = "tar.gz",
files = LICENSE_TARGETS,
mode = "0644",
package_dir = "kubernetes",
deps = [
":_node-bin",
],
)

pkg_tar(
name = "_server-bin",
files = SERVER_TARGETS + NODE_TARGETS + CLIENT_TARGETS + [
"//build:docker-artifacts",
],
mode = "0755",
package_dir = "server/bin",
visibility = ["//visibility:private"],
)

genrule(
name = "dummy",
outs = [".dummy"],
cmd = "touch $@",
)

# Some of the startup scripts fail if there isn't an addons/ directory in the server tarball.
pkg_tar(
name = "_server-addons",
files = [
":.dummy",
],
package_dir = "addons",
visibility = ["//visibility:private"],
)

pkg_tar(
name = "kubernetes-server-%s" % PLATFORM_ARCH_STRING,
extension = "tar.gz",
files = LICENSE_TARGETS,
mode = "0644",
package_dir = "kubernetes",
deps = [
":_server-addons",
":_server-bin",
],
)

pkg_tar(
name = "_test-bin",
files = TEST_BINARY_TARGETS,
mode = "0755",
package_dir = "platforms/" + PLATFORM_ARCH_STRING.replace("-", "/"),
# TODO: how to make this multiplatform?
visibility = ["//visibility:private"],
)

pkg_tar(
name = "kubernetes-test",
extension = "tar.gz",
files = TEST_PORTABLE_TARGETS,
package_dir = "kubernetes",
strip_prefix = "//",
deps = [
# TODO: how to make this multiplatform?
":_test-bin",
],
)

pkg_tar(
name = "_full_server",
files = [
":kubernetes-manifests.tar.gz",
":kubernetes-salt.tar.gz",
],
package_dir = "server",
visibility = ["//visibility:private"],
)

pkg_tar(
name = "kubernetes",
extension = "tar.gz",
files = [
"//:Godeps/LICENSES",
"//:README.md",
"//:Vagrantfile",
"//cluster:all-srcs",
"//docs:all-srcs",
"//examples:all-srcs",
"//third_party/htpasswd:all-srcs",
],
package_dir = "kubernetes",
strip_prefix = "//",
deps = [
":_full_server",
"//federation:release",
],
)

pkg_tar(
name = "kubernetes-manifests",
extension = "tar.gz",
deps = [
"//cluster:manifests",
],
)

pkg_tar(
name = "kubernetes-salt",
extension = "tar.gz",
deps = [
"//cluster/saltbase:salt",
],
)

filegroup(
name = "release-tars",
srcs = [
":kubernetes.tar.gz",
":kubernetes-client-%s.tar.gz" % PLATFORM_ARCH_STRING,
":kubernetes-node-%s.tar.gz" % PLATFORM_ARCH_STRING,
":kubernetes-server-%s.tar.gz" % PLATFORM_ARCH_STRING,
":kubernetes-manifests.tar.gz",
":kubernetes-salt.tar.gz",
":kubernetes-src.tar.gz",
":kubernetes-test.tar.gz",
],
)
27 changes: 27 additions & 0 deletions cluster/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

licenses(["notice"])

filegroup(
Expand All @@ -14,6 +16,31 @@ filegroup(
srcs = [
":package-srcs",
"//cluster/addons:all-srcs",
"//cluster/gce:all-srcs",
"//cluster/saltbase:all-srcs",
],
tags = ["automanaged"],
)

# All of the manifests that are expected to be in a "gci-trusty"
# subdir of the manifests tarball.
pkg_tar(
name = "_manifests-gci-trusty",
package_dir = "gci-trusty",
visibility = ["//visibility:private"],
deps = [
"//cluster/addons",
"//cluster/gce:gci-trusty-manifests",
"//cluster/saltbase:gci-trusty-salt-manifests",
],
)

pkg_tar(
name = "manifests",
mode = "0644",
package_dir = "kubernetes",
deps = [
":_manifests-gci-trusty",
"//cluster/saltbase:salt-manifests",
],
)
24 changes: 9 additions & 15 deletions cluster/addons/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

filegroup(
name = "addon-srcs",
srcs = glob([
"calico-policy-controller/*",
"cluster-loadbalancing/*",
"cluster-monitoring/*",
"dashboard/*",
"dns/*",
"etcd-empty-dir-cleanup/*",
"fluentd-elasticsearch/*",
"fluentd-gcp/*",
"gci/*",
"node-problem-detector/*",
"podsecuritypolicies/*",
"python-image/*",
"registry/*",
]),
srcs = glob(
[
"**/*.json",
"**/*.yaml",
"**/*.yaml.in",
],
exclude = ["**/*demo*/**"],
),
)

pkg_tar(
Expand All @@ -27,6 +20,7 @@ pkg_tar(
files = [
":addon-srcs",
],
mode = "0644",
strip_prefix = ".",
)

Expand Down
Loading

0 comments on commit bc4b6ac

Please sign in to comment.