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
d7c2c2a6
Commit
d7c2c2a6
authored
Mar 06, 2019
by
Jeff Grafton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bazel: refactor multi-arch container builds into starlark
parent
e7888f2c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
45 deletions
+94
-45
container.bzl
build/container.bzl
+72
-0
BUILD
cluster/images/conformance/BUILD
+12
-23
BUILD
cluster/images/hyperkube/BUILD
+10
-22
No files found.
build/container.bzl
0 → 100644
View file @
d7c2c2a6
# 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.
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image")
load("//build:platforms.bzl", "go_platform_constraint")
# multi_arch_container produces a private internal container_image, multiple
# arch-specific tagged container_bundles (named NAME-ARCH) and aliases
# from NAME and NAME.tar to the appropriately NAME-ARCH container_bundle target
# for the currently-configured architecture.
# Args:
# name: name used for the alias; the internal container_image and
# container_bundles are based on this name
# architectures: list of architectures (in GOARCH naming parlance) to
# configure
# base: base image to use for the containers. The format string {ARCH} will
# be replaced with the configured GOARCH.
# docker_tags: list of docker tags to apply to the image. The format string
# {ARCH} will be replaced with the configured GOARCH; any stamping variables
# should be escaped, e.g. {{STABLE_MY_VAR}}.
# tags: will be applied to all rules
# visiblity: will be applied only to the container_bundles; the internal
# container_image is private
# All other args will be applied to the internal container_image.
def multi_arch_container(
name,
architectures,
base,
docker_tags,
tags = None,
visibility = None,
**kwargs):
container_image(
name = "%s-internal" % name,
base = select({
go_platform_constraint(os = "linux", arch = arch): base.format(ARCH = arch)
for arch in architectures
}),
tags = tags,
visibility = ["//visibility:private"],
**kwargs
)
for arch in architectures:
container_bundle(
name = "%s-%s" % (name, arch),
images = {
docker_tag.format(ARCH = arch): ":%s-internal" % name
for docker_tag in docker_tags
},
tags = tags,
visibility = visibility,
)
for suffix in ["", ".tar"]:
native.alias(
name = "%s%s" % (name, suffix),
actual = select({
go_platform_constraint(os = "linux", arch = arch): "%s-%s%s" % (name, arch, suffix)
for arch in architectures
}),
)
cluster/images/conformance/BUILD
View file @
d7c2c2a6
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image", "container_layer")
load("//build:platforms.bzl", "SERVER_PLATFORMS", "for_platforms")
load("@io_bazel_rules_docker//container:container.bzl", "container_layer")
load("//build:platforms.bzl", "SERVER_PLATFORMS")
load("//build:container.bzl", "multi_arch_container")
container_layer(
name = "cluster-srcs",
...
...
@@ -18,17 +19,18 @@ container_layer(
],
)
container_image(
name = "conformance-internal",
base = select(for_platforms(
for_server = "@debian-hyperkube-base-{ARCH}//image",
only_os = "linux",
)),
multi_arch_container(
name = "conformance",
architectures = SERVER_PLATFORMS["linux"],
base = "@debian-hyperkube-base-{ARCH}//image",
cmd = [
"/bin/bash",
"-c",
"/run_e2e.sh",
],
# {ARCH} is replaced by the macro, but STABLE_DOCKER_TAG is replaced by the
# build stamping, so we need to escape it
docker_tags = ["k8s.gcr.io/conformance-{ARCH}:{{STABLE_DOCKER_TAG}}"],
env = {
"E2E_FOCUS": "\[Conformance\]",
"E2E_SKIP": "",
...
...
@@ -45,23 +47,10 @@ container_image(
":bins",
],
stamp = True,
workdir = "/usr/local/bin",
)
[container_bundle(
name = "conformance-%s" % arch,
images = {"k8s.gcr.io/conformance-%s:{STABLE_DOCKER_TAG}" % arch: "conformance-internal"},
tags = ["manual"],
visibility = ["//visibility:public"],
) for arch in SERVER_PLATFORMS["linux"]]
[alias(
name = "conformance%s" % suffix,
actual = select(for_platforms(for_server = "conformance-{ARCH}%s" % suffix)),
) for suffix in [
"",
".tar",
]]
workdir = "/usr/local/bin",
)
filegroup(
name = "package-srcs",
...
...
cluster/images/hyperkube/BUILD
View file @
d7c2c2a6
load("
@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image
")
load("//build:platforms.bzl", "SERVER_PLATFORMS"
, "for_platforms"
)
load("
//build:container.bzl", "multi_arch_container
")
load("//build:platforms.bzl", "SERVER_PLATFORMS")
container_image(
name = "hyperkube-internal",
base = select(for_platforms(
for_server = "@debian-hyperkube-base-{ARCH}//image",
only_os = "linux",
)),
multi_arch_container(
name = "hyperkube",
architectures = SERVER_PLATFORMS["linux"],
base = "@debian-hyperkube-base-{ARCH}//image",
# {ARCH} is replaced by the macro, but STABLE_DOCKER_TAG is replaced by the
# build stamping, so we need to escape it
docker_tags = ["k8s.gcr.io/hyperkube-{ARCH}:{{STABLE_DOCKER_TAG}}"],
files = [
"//cmd/hyperkube",
],
stamp = True,
)
[container_bundle(
name = "hyperkube-%s" % arch,
images = {"k8s.gcr.io/hyperkube-%s:{STABLE_DOCKER_TAG}" % arch: "hyperkube-internal"},
tags = ["manual"],
visibility = ["//visibility:public"],
) for arch in SERVER_PLATFORMS["linux"]]
[alias(
name = "hyperkube%s" % suffix,
actual = select(for_platforms(for_server = "hyperkube-{ARCH}%s" % suffix)),
) for suffix in [
"",
".tar",
]]
)
filegroup(
name = "package-srcs",
...
...
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