Skip to content

Commit

Permalink
Allow building a dev vizier release.
Browse files Browse the repository at this point in the history
Summary:
Adds options to ci/vizier_build_release.sh, that allow specifying a custom GCS bucket, and a custom container registry, so anyone can make a dev release that points to a bucket/registry they have access to.
This is useful for testing out changes to the YAML templatization without needing prod access, because there's no way to test those changes without cutting a release.

Test Plan: Tested by building a dev release pointing to a custom GCS bucket, and then pointing artifact server to that bucket. Successfully deployed vizier with the dev release.

Reviewers: zasgar, michelle, vihang

Reviewed By: michelle

Signed-off-by: James Bartlett <jamesbartlett@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D11701

GitOrigin-RevId: 0d98212
  • Loading branch information
JamesMBartlett authored and copybaranaut committed Jun 29, 2022
1 parent ed9d7e4 commit 7cf82b9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ci/vizier_build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,28 @@ bazel run -c opt //src/utils/artifacts/versions_gen:versions_gen -- \

public="True"
bucket="pixie-dev-public"
extra_bazel_args=()
if [[ $release_tag == *"-"* ]]; then
public="False"
bucket="pixie-prod-artifacts"
fi
if [[ -n $DEV_ARTIFACT_BUCKET ]]; then
public="False"
bucket="${DEV_ARTIFACT_BUCKET}"
if [[ -z $DEV_IMAGE_PREFIX ]]; then
echo "Must specify DEV_IMAGE_PREFIX, when specifying a dev release with DEV_ARTIFACT_BUCKET"
exit 1
fi
extra_bazel_args+=("--define" "DEV_VIZIER_IMAGE_PREFIX=${DEV_IMAGE_PREFIX}")
extra_bazel_args+=("--//k8s/vizier:use_dev_vizier_images")
fi

output_path="gs://${bucket}/vizier/${release_tag}"

bazel run --stamp -c opt --define BUNDLE_VERSION="${release_tag}" \
--stamp --define public="${public}" //k8s/vizier:vizier_images_push
--stamp --define public="${public}" //k8s/vizier:vizier_images_push "${extra_bazel_args[@]}"
bazel build --stamp -c opt --define BUNDLE_VERSION="${release_tag}" \
--stamp --define public="${public}" //k8s/vizier:vizier_yamls
--stamp --define public="${public}" //k8s/vizier:vizier_yamls "${extra_bazel_args[@]}"

output_path="gs://${bucket}/vizier/${release_tag}"
yamls_tar="${repo_path}/bazel-bin/k8s/vizier/vizier_yamls.tar"
Expand Down
45 changes: 45 additions & 0 deletions k8s/vizier/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# SPDX-License-Identifier: Apache-2.0

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle")
load("@io_bazel_rules_docker//contrib:push-all.bzl", "container_push")
Expand All @@ -33,6 +34,8 @@ VIZIER_IMAGE_MAP = {

public_image_replacement = {"gcr.io/pixie-oss/pixie-dev": "gcr.io/pixie-oss/pixie-prod"}

dev_image_replacement = {"gcr.io/pixie-oss/pixie-dev": "$(DEV_VIZIER_IMAGE_PREFIX)"}

generate_vizier_yamls(
name = "public_vizier_etcd_metadata_prod",
srcs = glob(["**/*.yaml"]),
Expand All @@ -49,6 +52,14 @@ generate_vizier_yamls(
replace = {},
)

generate_vizier_yamls(
name = "vizier_etcd_metadata_dev",
srcs = glob(["**/*.yaml"]),
out = "vizier_etcd_metadata_dev.yaml",
image_map = VIZIER_IMAGE_MAP,
replace = dev_image_replacement,
)

generate_vizier_metadata_persist_yamls(
name = "public_vizier_metadata_persist_prod",
srcs = glob(["**/*.yaml"]),
Expand All @@ -65,6 +76,14 @@ generate_vizier_metadata_persist_yamls(
replace = {},
)

generate_vizier_metadata_persist_yamls(
name = "vizier_metadata_persist_dev",
srcs = glob(["**/*.yaml"]),
out = "vizier_metadata_persist_dev.yaml",
image_map = VIZIER_IMAGE_MAP,
replace = dev_image_replacement,
)

container_bundle(
name = "private_vizier_images_bundle",
images = image_map_with_bundle_version(
Expand All @@ -83,15 +102,35 @@ container_bundle(
),
)

container_bundle(
name = "dev_vizier_images_bundle",
images = image_map_with_bundle_version(
image_map = VIZIER_IMAGE_MAP,
replace = dev_image_replacement,
tag_latest = False,
),
)

container_push(
name = "vizier_images_push",
bundle = select({
":dev": ":dev_vizier_images_bundle",
":public": ":public_vizier_images_bundle",
"//conditions:default": ":private_vizier_images_bundle",
}),
format = "Docker",
)

bool_flag(
name = "use_dev_vizier_images",
build_setting_default = False,
)

config_setting(
name = "dev",
flag_values = {":use_dev_vizier_images": "True"},
)

config_setting(
name = "public",
values = {"define": "public=True"},
Expand All @@ -101,6 +140,10 @@ pkg_tar(
name = "vizier_yamls",
srcs =
select({
":dev": [
"//k8s/vizier:vizier_etcd_metadata_dev.yaml",
"//k8s/vizier:vizier_metadata_persist_dev.yaml",
],
":public": [
"//k8s/vizier:public_vizier_etcd_metadata_prod.yaml",
"//k8s/vizier:public_vizier_metadata_persist_prod.yaml",
Expand All @@ -119,6 +162,8 @@ pkg_tar(
"/vizier/private_vizier_metadata_persist_prod.yaml": "vizier/vizier_metadata_persist_prod.yaml",
"/vizier/public_vizier_etcd_metadata_prod.yaml": "vizier/vizier_etcd_metadata_prod.yaml",
"/vizier/public_vizier_metadata_persist_prod.yaml": "vizier/vizier_metadata_persist_prod.yaml",
"/vizier/vizier_etcd_metadata_dev.yaml": "vizier/vizier_etcd_metadata_prod.yaml",
"/vizier/vizier_metadata_persist_dev.yaml": "vizier/vizier_metadata_persist_prod.yaml",
},
strip_prefix = "/k8s",
)

0 comments on commit 7cf82b9

Please sign in to comment.