Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5b7602a5
Commit
5b7602a5
authored
Mar 06, 2019
by
Jeff Grafton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bazel: refactor core docker images to use multi_arch_container
parent
d7c2c2a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
68 deletions
+22
-68
BUILD
build/BUILD
+22
-68
No files found.
build/BUILD
View file @
5b7602a5
package(default_visibility = ["//visibility:public"])
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image")
load("@io_k8s_repo_infra//defs:build.bzl", "release_filegroup")
load("@io_k8s_repo_infra//defs:build.bzl", "release_filegroup")
load(":code_generation_test.bzl", "code_generation_test_suite")
load(":code_generation_test.bzl", "code_generation_test_suite")
load(":container.bzl", "multi_arch_container")
load(":platforms.bzl", "SERVER_PLATFORMS", "for_platforms")
load(":platforms.bzl", "SERVER_PLATFORMS", "for_platforms")
code_generation_test_suite(
code_generation_test_suite(
...
@@ -31,100 +31,54 @@ filegroup(
...
@@ -31,100 +31,54 @@ filegroup(
# in build/common.sh.
# in build/common.sh.
DOCKERIZED_BINARIES = {
DOCKERIZED_BINARIES = {
"cloud-controller-manager": {
"cloud-controller-manager": {
"base": select(for_platforms(
"base": "@debian-base-{ARCH}//image",
for_node = "@debian-base-{ARCH}//image",
only_os = "linux",
)),
"target": "//cmd/cloud-controller-manager:cloud-controller-manager",
"target": "//cmd/cloud-controller-manager:cloud-controller-manager",
},
},
"kube-apiserver": {
"kube-apiserver": {
"base": select(for_platforms(
"base": "@debian-base-{ARCH}//image",
for_node = "@debian-base-{ARCH}//image",
only_os = "linux",
)),
"target": "//cmd/kube-apiserver:kube-apiserver",
"target": "//cmd/kube-apiserver:kube-apiserver",
},
},
"kube-controller-manager": {
"kube-controller-manager": {
"base": select(for_platforms(
"base": "@debian-base-{ARCH}//image",
for_node = "@debian-base-{ARCH}//image",
only_os = "linux",
)),
"target": "//cmd/kube-controller-manager:kube-controller-manager",
"target": "//cmd/kube-controller-manager:kube-controller-manager",
},
},
"kube-scheduler": {
"kube-scheduler": {
"base": select(for_platforms(
"base": "@debian-base-{ARCH}//image",
for_node = "@debian-base-{ARCH}//image",
only_os = "linux",
)),
"target": "//cmd/kube-scheduler:kube-scheduler",
"target": "//cmd/kube-scheduler:kube-scheduler",
},
},
"kube-proxy": {
"kube-proxy": {
"base": select(for_platforms(
"base": "@debian-iptables-{ARCH}//image",
for_node = "@debian-iptables-{ARCH}//image",
only_os = "linux",
)),
"target": "//cmd/kube-proxy:kube-proxy",
"target": "//cmd/kube-proxy:kube-proxy",
},
},
}
}
[[container_image(
name = "%s-internal-%s" % (binary, arch),
base = meta["base"],
cmd = ["/usr/bin/" + binary],
debs = ["//build/debs:%s-%s.deb" % (binary, arch)],
stamp = True,
symlinks = {
# Some cluster startup scripts expect to find the binaries in /usr/local/bin,
# but the debs install the binaries into /usr/bin.
"/usr/local/bin/" + binary: "/usr/bin/" + binary,
},
visibility = ["//visibility:private"],
) for binary, meta in DOCKERIZED_BINARIES.items()] for arch in SERVER_PLATFORMS["linux"]]
# Also create aliases for the arch-specific images defined above.
# The alias doesn't create a new file (like a genrule would);
# instead, we are using it with a select() conditional to
# be able to refer to the correct architecture in a consistent way.
# (Notably, container_bundle does not seem to support using a select()
# in the images attribute, so we defer that selection to this rule.)
[alias(
name = "%s-internal" % binary,
actual = select(for_platforms(
for_server = ":%s-internal-{ARCH}" % binary,
only_os = "linux",
)),
visibility = ["//visibility:private"],
) for binary in DOCKERIZED_BINARIES.keys()]
# We create two container bundles with the desired tags; one with an architecture in the name
# and one without.
# In the bash-based build (build/lib/release.sh), the images built for amd64 do not use
# In the bash-based build (build/lib/release.sh), the images built for amd64 do not use
# an arch in their name (but other arches do), and the GCE cluster scripts
# an arch in their name (but other arches do), and the GCE cluster scripts
# (which sideload the images via tarfiles) expect there not to be an arch.
# (which sideload the images via tarfiles) expect there not to be an arch.
# When pushing to gcr.io, we want to use an arch, since the archless name is now used for a
# When pushing to gcr.io, we want to use an arch, since the archless name is now used for a
# manifest list. Bazel doesn't support manifest lists (yet), so we can't do that either.
# manifest list. Bazel doesn't support manifest lists (yet), so we can't do that either.
#
Instead, f
or now, we use the archless name for the image tars saved in the server tarball,
#
F
or now, we use the archless name for the image tars saved in the server tarball,
# to satisfy GCE and other similar providers. (If one were to pull the images via the manifest
# to satisfy GCE and other similar providers. (If one were to pull the images via the manifest
# list, the arch wouldn't appear in the name either.)
# list, the arch wouldn't appear in the name either.)
# The bundle with the arch isn't used currently, but might be at some point for pushing to gcr.io
[multi_arch_container(
# and to then create a manifest list (possibly outside of bazel).
[[container_bundle(
name = "%s-%s" % (binary, arch),
images = {
"k8s.gcr.io/%s-%s:{STABLE_DOCKER_TAG}" % (binary, arch): "%s-internal-%s" % (binary, arch),
},
tags = ["manual"],
visibility = ["//visibility:public"],
) for binary in DOCKERIZED_BINARIES.keys()] for arch in SERVER_PLATFORMS["linux"]]
[container_bundle(
name = binary,
name = binary,
images = {
architectures = SERVER_PLATFORMS["linux"],
"k8s.gcr.io/%s:{STABLE_DOCKER_TAG}" % binary: binary + "-internal",
base = meta["base"],
cmd = ["/usr/bin/" + binary],
debs = select(for_platforms(
for_server = ["//build/debs:%s-{ARCH}.deb" % binary],
only_os = "linux",
)),
docker_tags = ["k8s.gcr.io/%s:{{STABLE_DOCKER_TAG}}" % binary],
stamp = True,
symlinks = {
# Some cluster startup scripts expect to find the binaries in /usr/local/bin,
# but the debs install the binaries into /usr/bin.
"/usr/local/bin/" + binary: "/usr/bin/" + binary,
},
},
tags = ["manual"],
tags = ["manual"],
visibility = ["//visibility:private"],
visibility = ["//visibility:private"],
) for binary
in DOCKERIZED_BINARIES.key
s()]
) for binary
, meta in DOCKERIZED_BINARIES.item
s()]
[genrule(
[genrule(
name = binary + "_docker_tag",
name = binary + "_docker_tag",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment