1"""imports linkerd manifests"""
2
3load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
4load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
5load("@rules_oci//oci:defs.bzl", "oci_image")
6load("//hack/build/rules/container:index.bzl", "container_push")
7load("//hack/tools/fetch-digests:fetch-digests.bzl", "fetch_digests")
8load("//hack/tools/helm:helm.bzl", "helm_template")
9load(":version.bzl", "IMAGES", "PROXY_INIT_IMAGES", "PROXY_INIT_VERSION", "REGISTRY", "REPO", "VERSION")
10
11package(default_visibility = ["//visibility:public"])
12
13# fetches digests for linkerd and prints to stdout
14fetch_digests(
15 name = "print-linkerd-digests",
16 images = IMAGES,
17 registry = REGISTRY,
18 repo = REPO,
19 tag = VERSION,
20)
21
22fetch_digests(
23 name = "print-proxy-init-digests",
24 images = PROXY_INIT_IMAGES,
25 registry = REGISTRY,
26 repo = REPO,
27 tag = PROXY_INIT_VERSION,
28)
29
30# copies and writes the helm chart to helm/linkerd/charts
31copy_to_directory(
32 name = "cp_linkerd_manifests",
33 srcs = ["@linkerd_manifests//:file"],
34 out = "linkerd-helm-chart",
35 allow_overwrites = True,
36 exclude_srcs_patterns = [
37 "charts/*.yml",
38 "charts/linkerd2-cni/**/*",
39 ],
40 include_external_repositories = ["**"],
41 include_srcs_patterns = ["charts/**/*"],
42 replace_prefixes = {
43 "charts/": "",
44 },
45)
46
47write_source_file(
48 name = "write_linkerd_manifests",
49 check_that_out_file_exists = False, # cant check a subpackage https://github.com/aspect-build/bazel-lib/blob/7a8f00cd7fc81024e26bf41cea4132ac9e080739/lib/tests/write_source_files/BUILD.bazel#L211
50 in_file = ":cp_linkerd_manifests",
51 out_file = "//third_party/k8s/linkerd/helm/linkerd:charts",
52)
53
54# The proxy image must be built and overwritten with the env var LINKERD2_PROXY_IDENTITY_MAX_REFRESH for lan outage requirement
55oci_image(
56 name = "linkerd_proxy",
57 base = "@linkerd_proxy",
58 env = {
59 "LINKERD2_PROXY_IDENTITY_MAX_REFRESH": "6h",
60 },
61 tags = ["manual"],
62)
63
64# bazel run third_party/k8s/linkerd/linkerd-proxy:container_push
65container_push(
66 name = "container_push",
67 image = ":linkerd_proxy",
68 # image_name = "{0}/{1}/proxy-ha".format(REGISTRY, REPO),
69 image_name = "ghcr.io/linkerd/proxy-ha",
70 repository_file = "//hack/build/rules/container:thirdparty-repo",
71 tag = VERSION,
72)
73
74helm_template(
75 name = "template_linkerd_crd_manifests",
76 chart = "@linkerd_helm_chart//:crd_file",
77 namespace = "linkerd",
78 release_name = "linkerd",
79 values_yaml = "@linkerd_helm_chart//:crd_chart_values",
80)
81
82write_source_file(
83 name = "write_rendered_crd_manifests",
84 check_that_out_file_exists = False, # cant check a subpackage https://github.com/aspect-build/bazel-lib/blob/7a8f00cd7fc81024e26bf41cea4132ac9e080739/lib/tests/write_source_files/BUILD.bazel#L211
85 diff_test = False,
86 in_file = ":template_linkerd_crd_manifests",
87 out_file = "//config/pallets/linkerdctl/linkerd-crds:linkerd-crds.yaml",
88)
View as plain text