Skip to content

Latest commit

 

History

History
84 lines (64 loc) · 4.88 KB

multi_deploy.md

File metadata and controls

84 lines (64 loc) · 4.88 KB

Public API for container image multi deploy rule.

multi_deploy

load("@rules_img//img:multi_deploy.bzl", "multi_deploy")

multi_deploy(name, deploy_operations, deploy_tool, load_strategy, operations, push_strategy,
             tool_cfg)

Deploys multiple container images in a single coordinated command.

Use push_specs and load_specs on your image targets to attach deployment configuration directly, then reference the images in operations:

load("@rules_img//img:image.bzl", "image_manifest")
load("@rules_img//img:push.bzl", "image_push_spec")
load("@rules_img//img:multi_deploy.bzl", "multi_deploy")

image_push_spec(
    name = "push_spec",
    registry = "gcr.io",
    repository = "my-project/{{.image_target_name}}",
    tag = "latest",
)

image_manifest(
    name = "frontend",
    base = "@distroless_cc",
    layers = [":frontend_layer"],
    push_specs = [":push_spec"],
)

image_manifest(
    name = "backend",
    base = "@distroless_cc",
    layers = [":backend_layer"],
    push_specs = [":push_spec"],
)

multi_deploy(
    name = "deploy_all",
    operations = [
        ":frontend",
        ":backend",
    ],
)

Alternatively, standalone image_push or image_load targets that already provide DeployInfo can be used directly in operations, as can custom targets that provide MultipleDeployInfo to contribute several deploy operations at once.

multi_deploy has no push at build time of its own; it deploys at bazel run time. When push_at_build_time is enabled, the image_push targets (or images with push_specs) referenced here already push at build time on their own — multi_deploy does not push them a second time.

Runtime usage:

bazel run //path/to:deploy_all

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deploy_operations Which kinds of deploy operations to perform.

Acts as a filter when assembling the final deploy manifest from all operations:

- "push": include push operations (and their associated registry tag operations). - "load": include load operations.

Defaults to ["push", "load"], performing every operation contributed by the operations targets. Narrow it when your images carry both push_specs and load_specs but a particular deployment should only push or only load -- for example, ["push"] to push without loading, or ["load"] to load without pushing.
List of strings optional ["push", "load"]
deploy_tool Optional label of a deploy tool target providing DeployToolInfo (created with img_deploy_tool from @rules_img//img:deploy_tool.bzl). When set, overrides tool_cfg. Label optional None
load_strategy Load strategy to use for all load operations in the deployment.

Available strategies: - auto (default): Uses the global default load strategy - eager: Downloads all layers during the build phase - lazy: Downloads layers only when needed during the load operation
String optional "auto"
operations List of operations to deploy together.

Each operation must provide DeployInfo (typically from image_push, image_load, image_manifest with push_specs/load_specs, or image_index with push_specs/load_specs) or MultipleDeployInfo (whose infos are expanded in place). All operations will be merged and executed in the order specified.

A MultipleDeployInfo with no infos is allowed and results in a no-op instead of an error.
List of labels required
push_strategy Push strategy to use for all push operations in the deployment.

See push strategies documentation for detailed information.
String optional "auto"
tool_cfg Configuration of the deployer executable platform.

Available options: - host (default): Deployer executable matches the host platform. - target: Deployer executable matches the target platform(s) specified via --platforms.
String optional "host"