BUILD 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package(default_visibility = ["//visibility:public"])
  2. load("@io_k8s_repo_infra//defs:build.bzl", "release_filegroup")
  3. load(":code_generation_test.bzl", "code_generation_test_suite")
  4. load(":container.bzl", "multi_arch_container", "multi_arch_container_push")
  5. load(":platforms.bzl", "SERVER_PLATFORMS", "for_platforms")
  6. code_generation_test_suite(
  7. name = "code_generation_tests",
  8. )
  9. filegroup(
  10. name = "package-srcs",
  11. srcs = glob(["**"]),
  12. tags = ["automanaged"],
  13. )
  14. filegroup(
  15. name = "all-srcs",
  16. srcs = [
  17. ":package-srcs",
  18. "//build/debs:all-srcs",
  19. "//build/release-tars:all-srcs",
  20. "//build/rpms:all-srcs",
  21. "//build/visible_to:all-srcs",
  22. ],
  23. tags = ["automanaged"],
  24. )
  25. # This list should roughly match kube::build::get_docker_wrapped_binaries()
  26. # in build/common.sh.
  27. DOCKERIZED_BINARIES = {
  28. "cloud-controller-manager": {
  29. "base": "@debian-base-{ARCH}//image",
  30. "target": "//cmd/cloud-controller-manager:cloud-controller-manager",
  31. },
  32. "kube-apiserver": {
  33. "base": "@debian-base-{ARCH}//image",
  34. "target": "//cmd/kube-apiserver:kube-apiserver",
  35. },
  36. "kube-controller-manager": {
  37. "base": "@debian-base-{ARCH}//image",
  38. "target": "//cmd/kube-controller-manager:kube-controller-manager",
  39. },
  40. "kube-scheduler": {
  41. "base": "@debian-base-{ARCH}//image",
  42. "target": "//cmd/kube-scheduler:kube-scheduler",
  43. },
  44. "kube-proxy": {
  45. "base": "@debian-iptables-{ARCH}//image",
  46. "target": "//cmd/kube-proxy:kube-proxy",
  47. },
  48. }
  49. # In the bash-based build (build/lib/release.sh), the images built for amd64 do not use
  50. # an arch in their name (but other arches do), and the GCE cluster scripts
  51. # (which sideload the images via tarfiles) expect there not to be an arch.
  52. # When pushing to gcr.io, we want to use an arch, since the archless name is now used for a
  53. # manifest list. Bazel doesn't support manifest lists (yet), so we can't do that either.
  54. # For now, we use the archless name for the image tars saved in the server tarball,
  55. # to satisfy GCE and other similar providers. (If one were to pull the images via the manifest
  56. # list, the arch wouldn't appear in the name either.)
  57. [multi_arch_container(
  58. name = binary,
  59. architectures = SERVER_PLATFORMS["linux"],
  60. base = meta["base"],
  61. cmd = ["/usr/bin/" + binary],
  62. debs = select(for_platforms(
  63. for_server = ["//build/debs:%s-{ARCH}.deb" % binary],
  64. only_os = "linux",
  65. )),
  66. # Since the multi_arch_container macro replaces the {ARCH} format string,
  67. # we need to escape the stamping vars.
  68. # Also see comment above about why the push tags use ARCH while the
  69. # non-push tags do not.
  70. docker_push_tags = ["{{STABLE_DOCKER_PUSH_REGISTRY}}/%s-{ARCH}:{{STABLE_DOCKER_TAG}}" % binary],
  71. docker_tags = ["{{STABLE_DOCKER_REGISTRY}}/%s:{{STABLE_DOCKER_TAG}}" % binary],
  72. stamp = True,
  73. symlinks = {
  74. # Some cluster startup scripts expect to find the binaries in /usr/local/bin,
  75. # but the debs install the binaries into /usr/bin.
  76. "/usr/local/bin/" + binary: "/usr/bin/" + binary,
  77. },
  78. tags = ["manual"],
  79. visibility = ["//visibility:private"],
  80. ) for binary, meta in DOCKERIZED_BINARIES.items()]
  81. # Also roll up all images into a single bundle to push with one target.
  82. multi_arch_container_push(
  83. name = "server-images",
  84. architectures = SERVER_PLATFORMS["linux"],
  85. docker_tags_images = {
  86. "{{STABLE_DOCKER_PUSH_REGISTRY}}/%s-{ARCH}:{{STABLE_DOCKER_TAG}}" % binary: "%s-internal" % binary
  87. for binary in DOCKERIZED_BINARIES.keys()
  88. },
  89. tags = ["manual"],
  90. )
  91. [genrule(
  92. name = binary + "_docker_tag",
  93. srcs = [meta["target"]],
  94. outs = [binary + ".docker_tag"],
  95. cmd = "grep ^STABLE_DOCKER_TAG bazel-out/stable-status.txt | awk '{print $$2}' >$@",
  96. stamp = 1,
  97. ) for binary, meta in DOCKERIZED_BINARIES.items()]
  98. genrule(
  99. name = "os_package_version",
  100. outs = ["version"],
  101. cmd = """
  102. grep ^STABLE_BUILD_SCM_REVISION bazel-out/stable-status.txt \
  103. | awk '{print $$2}' \
  104. | sed -e 's/^v//' -Ee 's/-([a-z]+)/~\\1/' -e 's/-/+/g' \
  105. >$@
  106. """,
  107. stamp = 1,
  108. )
  109. release_filegroup(
  110. name = "docker-artifacts",
  111. srcs = [":%s.tar" % binary for binary in DOCKERIZED_BINARIES.keys()] +
  112. [":%s.docker_tag" % binary for binary in DOCKERIZED_BINARIES.keys()],
  113. )
  114. # KUBE_CLIENT_TARGETS
  115. release_filegroup(
  116. name = "client-targets",
  117. conditioned_srcs = for_platforms(for_client = [
  118. "//cmd/kubectl",
  119. ]),
  120. )
  121. # KUBE_NODE_TARGETS
  122. release_filegroup(
  123. name = "node-targets",
  124. conditioned_srcs = for_platforms(for_node = [
  125. "//cmd/kube-proxy",
  126. "//cmd/kubeadm",
  127. "//cmd/kubelet",
  128. ]),
  129. )
  130. # KUBE_SERVER_TARGETS
  131. # No need to duplicate CLIENT_TARGETS or NODE_TARGETS here,
  132. # since we include them in the actual build rule.
  133. release_filegroup(
  134. name = "server-targets",
  135. conditioned_srcs = for_platforms(for_server = [
  136. "//cluster/gce/gci/mounter",
  137. "//cmd/cloud-controller-manager",
  138. "//cmd/hyperkube",
  139. "//cmd/kube-apiserver",
  140. "//cmd/kube-controller-manager",
  141. "//cmd/kube-scheduler",
  142. ]),
  143. )
  144. # kube::golang::test_targets
  145. filegroup(
  146. name = "test-targets",
  147. srcs = select(for_platforms(
  148. for_server = [
  149. "//cmd/kubemark",
  150. "//test/e2e_node:e2e_node.test_binary",
  151. ],
  152. for_test = [
  153. "//cmd/gendocs",
  154. "//cmd/genkubedocs",
  155. "//cmd/genman",
  156. "//cmd/genswaggertypedocs",
  157. "//cmd/genyaml",
  158. "//cmd/linkcheck",
  159. "//test/e2e:e2e.test_binary",
  160. "//vendor/github.com/onsi/ginkgo/ginkgo",
  161. ],
  162. )),
  163. )
  164. # KUBE_TEST_PORTABLE
  165. filegroup(
  166. name = "test-portable-targets",
  167. srcs = [
  168. "//hack:e2e.go",
  169. "//hack:get-build.sh",
  170. "//hack:ginkgo-e2e.sh",
  171. "//hack/e2e-internal:all-srcs",
  172. "//hack/lib:all-srcs",
  173. "//test/e2e/testing-manifests:all-srcs",
  174. "//test/kubemark:all-srcs",
  175. ],
  176. )