diff --git a/build/platforms.bzl b/build/platforms.bzl new file mode 100644 index 0000000000..4ab1349534 --- /dev/null +++ b/build/platforms.bzl @@ -0,0 +1,75 @@ +# Copyright 2019 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. + +# KUBE_SERVER_PLATFORMS in hack/lib/golang.sh +SERVER_PLATFORMS = { + "linux": [ + "amd64", + "arm", + "arm64", + "ppc64le", + "s390x", + ], +} + +# KUBE_NODE_PLATFORMS in hack/lib/golang.sh +NODE_PLATFORMS = { + "linux": [ + "amd64", + "arm", + "arm64", + "ppc64le", + "s390x", + ], + "windows": [ + "amd64", + ], +} + +# KUBE_CLIENT_PLATFORMS in hack/lib/golang.sh +CLIENT_PLATFORMS = { + "linux": [ + "386", + "amd64", + "arm", + "arm64", + "ppc64le", + "s390x", + ], + "darwin": [ + "386", + "amd64", + ], + "windows": [ + "386", + "amd64", + ], +} + +# KUBE_TEST_PLATFORMS in hack/lib/golang.sh +TEST_PLATFORMS = { + "linux": [ + "amd64", + "arm", + "arm64", + "s390x", + "ppc64le", + ], + "darwin": [ + "amd64", + ], + "windows": [ + "amd64", + ], +} diff --git a/build/root/WORKSPACE b/build/root/WORKSPACE index 24fd8d277e..43e2868bda 100644 --- a/build/root/WORKSPACE +++ b/build/root/WORKSPACE @@ -1,6 +1,5 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") load("//build:workspace_mirror.bzl", "mirror") -load("//build:workspace.bzl", "CNI_VERSION", "CRI_TOOLS_VERSION") http_archive( name = "bazel_skylib", @@ -60,44 +59,6 @@ container_repositories() load("@io_bazel_rules_docker//container:container.bzl", "container_pull") -http_file( - name = "kubernetes_cni", - downloaded_file_path = "kubernetes_cni.tgz", - sha256 = "f04339a21b8edf76d415e7f17b620e63b8f37a76b2f706671587ab6464411f2d", - urls = mirror("https://storage.googleapis.com/kubernetes-release/network-plugins/cni-plugins-amd64-v%s.tgz" % CNI_VERSION), -) - -http_file( - name = "cri_tools", - downloaded_file_path = "cri_tools.tgz", - sha256 = "e7d913bcce40bf54e37ab1d4b75013c823d0551e6bc088b217bc1893207b4844", - urls = mirror("https://github.com/kubernetes-incubator/cri-tools/releases/download/v%s/crictl-v%s-linux-amd64.tar.gz" % (CRI_TOOLS_VERSION, CRI_TOOLS_VERSION)), -) - -container_pull( - name = "debian-base-amd64", - digest = "sha256:8ccb65cd2dd7e0c24193d0742a20e4a673dbd11af5a33f16fcd471a31486866c", - registry = "k8s.gcr.io", - repository = "debian-base-amd64", - tag = "0.4.1", # ignored, but kept here for documentation -) - -container_pull( - name = "debian-iptables-amd64", - digest = "sha256:9c41b4c326304b94eb96fdd2e181aa6e9995cc4642fcdfb570cedd73a419ba39", - registry = "k8s.gcr.io", - repository = "debian-iptables-amd64", - tag = "v11.0.1", # ignored, but kept here for documentation -) - -container_pull( - name = "debian-hyperkube-base-amd64", - digest = "sha256:5d4ea2fb5fbe9a9a9da74f67cf2faefc881968bc39f2ac5d62d9167e575812a1", - registry = "k8s.gcr.io", - repository = "debian-hyperkube-base-amd64", - tag = "0.12.1", # ignored, but kept here for documentation -) - container_pull( name = "official_busybox", digest = "sha256:cb63aa0641a885f54de20f61d152187419e8f6b159ed11a251a09d115fdff9bd", @@ -106,6 +67,10 @@ container_pull( tag = "latest", # ignored, but kept here for documentation ) +load("//build:workspace.bzl", "release_dependencies") + +release_dependencies() + load("//build:workspace_mirror.bzl", "export_urls") export_urls("workspace_urls") diff --git a/build/workspace.bzl b/build/workspace.bzl index edd2af76e7..6a0252e7c4 100644 --- a/build/workspace.bzl +++ b/build/workspace.bzl @@ -12,6 +12,83 @@ # See the License for the specific language governing permissions and # limitations under the License. -CRI_TOOLS_VERSION = "1.12.0" +load("//build:platforms.bzl", "SERVER_PLATFORMS") +load("//build:workspace_mirror.bzl", "mirror") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") +load("@io_bazel_rules_docker//container:container.bzl", "container_pull") CNI_VERSION = "0.6.0" +_CNI_TARBALL_ARCH_SHA256 = { + "amd64": "f04339a21b8edf76d415e7f17b620e63b8f37a76b2f706671587ab6464411f2d", + "arm": "ffb62021d2fc6e1266dc6ef7f2058125b6e6b44c016291a2b04a15ed9b4be70a", + "arm64": "016bbc989877e35e3cd49fafe11415fb2717e52c74fde6b1650411154cb91b81", + "ppc64le": "dd38dec69b167cfe40ecbba4b18cfe5b4296f2e49b90c00804b3988ef968e859", + "s390x": "7708289eee7e52ad055407c421033d8e593f5cf1a0b43a872f09eb4e1508aafc", +} + +CRI_TOOLS_VERSION = "1.12.0" +_CRI_TARBALL_ARCH_SHA256 = { + "amd64": "e7d913bcce40bf54e37ab1d4b75013c823d0551e6bc088b217bc1893207b4844", + "arm": "ca6b4ac80278d32d9cc8b8b19de140fd1cc35640f088969f7068fea2df625490", + "arm64": "8466f08b59bf36d2eebcb9428c3d4e6e224c3065d800ead09ad730ce374da6fe", + "ppc64le": "ec6254f1f6ffa064ba41825aab5612b7b005c8171fbcdac2ca3927d4e393000f", + "s390x": "814aa9cd496be416612c2653097a1c9eb5784e38aa4889034b44ebf888709057", +} + +# Note that these are digests for the manifest list. We resolve the manifest +# list to each of its platform-specific images in +# debian_image_dependencies(). +_DEBIAN_BASE_DIGEST = "sha256:6966a0aedd7592c18ff2dd803c08bd85780ee19f5e3a2e7cf908a4cd837afcde" # 0.4.1 +_DEBIAN_IPTABLES_DIGEST = "sha256:656e45c00083359107b1d6ae0411ff3894ba23011a8533e229937a71be84e063" # v11.0.1 +_DEBIAN_HYPERKUBE_BASE_DIGEST = "sha256:8cabe02be6e86685d8860b7ace7c7addc9591a339728703027a4854677f1c772" # 0.12.1 + +# Dependencies needed for a Kubernetes "release", e.g. building docker images, +# debs, RPMs, or tarballs. +def release_dependencies(): + cni_tarballs() + cri_tarballs() + debian_image_dependencies() + +def cni_tarballs(): + for arch, sha in _CNI_TARBALL_ARCH_SHA256.items(): + http_file( + name = "kubernetes_cni_%s" % arch, + downloaded_file_path = "kubernetes_cni.tgz", + sha256 = sha, + urls = mirror("https://storage.googleapis.com/kubernetes-release/network-plugins/cni-plugins-%s-v%s.tgz" % (arch, CNI_VERSION)), + ) + +def cri_tarballs(): + for arch, sha in _CRI_TARBALL_ARCH_SHA256.items(): + http_file( + name = "cri_tools_%s" % arch, + downloaded_file_path = "cri_tools.tgz", + sha256 = sha, + urls = mirror("https://github.com/kubernetes-incubator/cri-tools/releases/download/v%s/crictl-v%s-linux-%s.tar.gz" % (CRI_TOOLS_VERSION, CRI_TOOLS_VERSION, arch)), + ) + +def debian_image_dependencies(): + for arch in SERVER_PLATFORMS["linux"]: + container_pull( + name = "debian-base-" + arch, + architecture = arch, + digest = _DEBIAN_BASE_DIGEST, + registry = "k8s.gcr.io", + repository = "debian-base", + ) + + container_pull( + name = "debian-iptables-" + arch, + architecture = arch, + digest = _DEBIAN_IPTABLES_DIGEST, + registry = "k8s.gcr.io", + repository = "debian-iptables", + ) + + container_pull( + name = "debian-hyperkube-base-" + arch, + architecture = arch, + digest = _DEBIAN_HYPERKUBE_BASE_DIGEST, + registry = "k8s.gcr.io", + repository = "debian-hyperkube-base", + )