Skip to content

Commit

Permalink
new virt-exportserver container
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Henriksen <[email protected]>
  • Loading branch information
mhenriks committed Jun 15, 2022
1 parent 53cf99e commit a4bfc75
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 1 deletion.
9 changes: 9 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ container_push(
tag = "$(container_tag)",
)

container_push(
name = "push-virt-exportserver",
format = "Docker",
image = "//cmd/virt-exportserver:virt-exportserver-image",
registry = "$(container_prefix)",
repository = "$(image_prefix)virt-exportserver-image",
tag = "$(container_tag)",
)

genrule(
name = "build-virtctl",
srcs = [
Expand Down
81 changes: 81 additions & 0 deletions cmd/virt-exportserver/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["virt-exportserver.go"],
importpath = "kubevirt.io/kubevirt/cmd/virt-exportserver",
visibility = ["//visibility:private"],
)

load("//vendor/kubevirt.io/client-go/version:def.bzl", "version_x_defs")

go_binary(
name = "virt-exportserver",
embed = [":go_default_library"],
static = "on",
visibility = ["//visibility:public"],
x_defs = version_x_defs(),
)

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image",
)
load("@io_bazel_rules_docker//contrib:passwd.bzl", "passwd_entry", "passwd_file")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

passwd_entry(
name = "nonroot-user",
gid = 1001,
home = "/home/nonroot-user",
shell = "/bin/bash",
uid = 1001,
username = "nonroot-user",
)

passwd_file(
name = "passwd",
entries = [
":nonroot-user",
],
)

pkg_tar(
name = "passwd-tar",
srcs = [":passwd"],
mode = "0644",
package_dir = "etc",
visibility = ["//visibility:public"],
)

container_image(
name = "version-container",
directory = "/",
files = [
"//:get-version",
],
tars = select({
"@io_bazel_rules_go//go/platform:linux_arm64": [
":passwd-tar",
"//rpm:exportserverbase_aarch64",
],
"//conditions:default": [
":passwd-tar",
"//rpm:exportserverbase_x86_64",
],
}),
)

container_image(
name = "virt-exportserver-image",
architecture = select({
"@io_bazel_rules_go//go/platform:linux_arm64": "arm64",
"//conditions:default": "amd64",
}),
base = ":version-container",
directory = "/usr/bin/",
entrypoint = ["/usr/bin/virt-exportserver"],
files = [":virt-exportserver"],
user = "1001",
visibility = ["//visibility:public"],
)
32 changes: 32 additions & 0 deletions cmd/virt-exportserver/virt-exportserver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright 2018 Red Hat, Inc.
*
*/

package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("Hello World")
time.Sleep(time.Second)
}
}
2 changes: 1 addition & 1 deletion hack/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ source hack/common.sh
source hack/bootstrap.sh
source hack/config.sh

PUSH_TARGETS=(${PUSH_TARGETS:-other-images virt-operator virt-api virt-controller virt-handler virt-launcher conformance libguestfs})
PUSH_TARGETS=(${PUSH_TARGETS:-other-images virt-operator virt-api virt-controller virt-handler virt-launcher virt-exportserver conformance libguestfs})

for tag in ${docker_tag} ${docker_tag_alt}; do
for target in ${PUSH_TARGETS[@]}; do
Expand Down
26 changes: 26 additions & 0 deletions hack/rpm-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ libguestfstools_x86_64="
edk2-ovmf-${EDK2_VERSION}
"

exportserver_base="
tar
"

if [ -z "${SINGLE_ARCH}" ] || [ "${SINGLE_ARCH}" == "x86_64" ]; then

bazel run \
Expand Down Expand Up @@ -213,6 +217,17 @@ if [ -z "${SINGLE_ARCH}" ] || [ "${SINGLE_ARCH}" == "x86_64" ]; then
--force-ignore-with-dependencies '^(man-db|mandoc)' \
--force-ignore-with-dependencies '^dbus'

bazel run \
--config=${ARCHITECTURE} \
//:bazeldnf -- rpmtree \
--public --nobest \
--name exportserverbase_x86_64 \
--basesystem centos-stream-release \
${bazeldnf_repos} \
$centos_base \
$centos_extra \
$exportserver_base

# remove all RPMs which are no longer referenced by a rpmtree
bazel run \
--config=${ARCHITECTURE} \
Expand Down Expand Up @@ -294,6 +309,17 @@ if [ -z "${SINGLE_ARCH}" ] || [ "${SINGLE_ARCH}" == "aarch64" ]; then
$handler_base \
$handlerbase_extra

bazel run \
--config=${ARCHITECTURE} \
//:bazeldnf -- rpmtree \
--public --nobest \
--name exportserverbase_aarch64 --arch aarch64 \
--basesystem centos-stream-release \
${bazeldnf_repos} \
$centos_base \
$centos_extra \
$exportserver_base

# remove all RPMs which are no longer referenced by a rpmtree
bazel run \
--config=${ARCHITECTURE} \
Expand Down
114 changes: 114 additions & 0 deletions rpm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,120 @@ bazeldnf(
rulename = "libvirt-libs_aarch64",
)

rpmtree(
name = "exportserverbase_aarch64",
rpms = [
"@acl-0__2.2.53-1.el8.aarch64//rpm",
"@basesystem-0__11-5.el8.aarch64//rpm",
"@bash-0__4.4.20-3.el8.aarch64//rpm",
"@ca-certificates-0__2021.2.50-82.el8.aarch64//rpm",
"@centos-gpg-keys-1__8-6.el8.aarch64//rpm",
"@centos-stream-release-0__8.6-1.el8.aarch64//rpm",
"@centos-stream-repos-0__8-6.el8.aarch64//rpm",
"@chkconfig-0__1.19.1-1.el8.aarch64//rpm",
"@coreutils-single-0__8.30-12.el8.aarch64//rpm",
"@crypto-policies-0__20211116-1.gitae470d6.el8.aarch64//rpm",
"@curl-0__7.61.1-22.el8.aarch64//rpm",
"@filesystem-0__3.8-6.el8.aarch64//rpm",
"@gawk-0__4.2.1-4.el8.aarch64//rpm",
"@glibc-0__2.28-196.el8.aarch64//rpm",
"@glibc-common-0__2.28-196.el8.aarch64//rpm",
"@glibc-minimal-langpack-0__2.28-196.el8.aarch64//rpm",
"@gmp-1__6.1.2-10.el8.aarch64//rpm",
"@grep-0__3.1-6.el8.aarch64//rpm",
"@info-0__6.5-7.el8_5.aarch64//rpm",
"@keyutils-libs-0__1.5.10-9.el8.aarch64//rpm",
"@krb5-libs-0__1.18.2-14.el8.aarch64//rpm",
"@libacl-0__2.2.53-1.el8.aarch64//rpm",
"@libattr-0__2.4.48-3.el8.aarch64//rpm",
"@libcap-0__2.48-2.el8.aarch64//rpm",
"@libcom_err-0__1.45.6-4.el8.aarch64//rpm",
"@libcurl-minimal-0__7.61.1-22.el8.aarch64//rpm",
"@libffi-0__3.1-23.el8.aarch64//rpm",
"@libgcc-0__8.5.0-10.el8.aarch64//rpm",
"@libnghttp2-0__1.33.0-3.el8_2.1.aarch64//rpm",
"@libselinux-0__2.9-5.el8.aarch64//rpm",
"@libsepol-0__2.9-3.el8.aarch64//rpm",
"@libsigsegv-0__2.11-5.el8.aarch64//rpm",
"@libtasn1-0__4.13-3.el8.aarch64//rpm",
"@libverto-0__0.3.0-5.el8.aarch64//rpm",
"@mpfr-0__3.1.6-1.el8.aarch64//rpm",
"@ncurses-base-0__6.1-9.20180224.el8.aarch64//rpm",
"@ncurses-libs-0__6.1-9.20180224.el8.aarch64//rpm",
"@openssl-libs-1__1.1.1k-6.el8.aarch64//rpm",
"@p11-kit-0__0.23.22-1.el8.aarch64//rpm",
"@p11-kit-trust-0__0.23.22-1.el8.aarch64//rpm",
"@pcre-0__8.42-6.el8.aarch64//rpm",
"@pcre2-0__10.32-2.el8.aarch64//rpm",
"@popt-0__1.18-1.el8.aarch64//rpm",
"@readline-0__7.0-10.el8.aarch64//rpm",
"@sed-0__4.5-5.el8.aarch64//rpm",
"@setup-0__2.12.2-6.el8.aarch64//rpm",
"@tar-2__1.30-5.el8.aarch64//rpm",
"@tzdata-0__2022a-1.el8.aarch64//rpm",
"@vim-minimal-2__8.0.1763-16.el8_5.12.aarch64//rpm",
"@zlib-0__1.2.11-17.el8.aarch64//rpm",
],
visibility = ["//visibility:public"],
)

rpmtree(
name = "exportserverbase_x86_64",
rpms = [
"@acl-0__2.2.53-1.el8.x86_64//rpm",
"@basesystem-0__11-5.el8.x86_64//rpm",
"@bash-0__4.4.20-3.el8.x86_64//rpm",
"@ca-certificates-0__2021.2.50-82.el8.x86_64//rpm",
"@centos-gpg-keys-1__8-6.el8.x86_64//rpm",
"@centos-stream-release-0__8.6-1.el8.x86_64//rpm",
"@centos-stream-repos-0__8-6.el8.x86_64//rpm",
"@chkconfig-0__1.19.1-1.el8.x86_64//rpm",
"@coreutils-single-0__8.30-12.el8.x86_64//rpm",
"@crypto-policies-0__20211116-1.gitae470d6.el8.x86_64//rpm",
"@curl-0__7.61.1-22.el8.x86_64//rpm",
"@filesystem-0__3.8-6.el8.x86_64//rpm",
"@gawk-0__4.2.1-4.el8.x86_64//rpm",
"@glibc-0__2.28-196.el8.x86_64//rpm",
"@glibc-common-0__2.28-196.el8.x86_64//rpm",
"@glibc-minimal-langpack-0__2.28-196.el8.x86_64//rpm",
"@gmp-1__6.1.2-10.el8.x86_64//rpm",
"@grep-0__3.1-6.el8.x86_64//rpm",
"@info-0__6.5-7.el8_5.x86_64//rpm",
"@keyutils-libs-0__1.5.10-9.el8.x86_64//rpm",
"@krb5-libs-0__1.18.2-14.el8.x86_64//rpm",
"@libacl-0__2.2.53-1.el8.x86_64//rpm",
"@libattr-0__2.4.48-3.el8.x86_64//rpm",
"@libcap-0__2.48-2.el8.x86_64//rpm",
"@libcom_err-0__1.45.6-4.el8.x86_64//rpm",
"@libcurl-minimal-0__7.61.1-22.el8.x86_64//rpm",
"@libffi-0__3.1-23.el8.x86_64//rpm",
"@libgcc-0__8.5.0-10.el8.x86_64//rpm",
"@libnghttp2-0__1.33.0-3.el8_2.1.x86_64//rpm",
"@libselinux-0__2.9-5.el8.x86_64//rpm",
"@libsepol-0__2.9-3.el8.x86_64//rpm",
"@libsigsegv-0__2.11-5.el8.x86_64//rpm",
"@libtasn1-0__4.13-3.el8.x86_64//rpm",
"@libverto-0__0.3.0-5.el8.x86_64//rpm",
"@mpfr-0__3.1.6-1.el8.x86_64//rpm",
"@ncurses-base-0__6.1-9.20180224.el8.x86_64//rpm",
"@ncurses-libs-0__6.1-9.20180224.el8.x86_64//rpm",
"@openssl-libs-1__1.1.1k-6.el8.x86_64//rpm",
"@p11-kit-0__0.23.22-1.el8.x86_64//rpm",
"@p11-kit-trust-0__0.23.22-1.el8.x86_64//rpm",
"@pcre-0__8.42-6.el8.x86_64//rpm",
"@pcre2-0__10.32-2.el8.x86_64//rpm",
"@popt-0__1.18-1.el8.x86_64//rpm",
"@readline-0__7.0-10.el8.x86_64//rpm",
"@sed-0__4.5-5.el8.x86_64//rpm",
"@setup-0__2.12.2-6.el8.x86_64//rpm",
"@tar-2__1.30-5.el8.x86_64//rpm",
"@tzdata-0__2022a-1.el8.x86_64//rpm",
"@vim-minimal-2__8.0.1763-16.el8_5.12.x86_64//rpm",
"@zlib-0__1.2.11-17.el8.x86_64//rpm",
],
visibility = ["//visibility:public"],
)

rpmtree(
name = "handlerbase_aarch64",
rpms = [
Expand Down

0 comments on commit a4bfc75

Please sign in to comment.