https://github.com/pseudomuto/rules_kustomization
A bazel macro for generating kustomize bases
https://github.com/pseudomuto/rules_kustomization
bazel bazel-rules kustomize
Last synced: about 1 year ago
JSON representation
A bazel macro for generating kustomize bases
- Host: GitHub
- URL: https://github.com/pseudomuto/rules_kustomization
- Owner: pseudomuto
- License: mit
- Created: 2021-10-03T13:55:13.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-04T12:49:29.000Z (over 4 years ago)
- Last Synced: 2025-01-30T14:52:44.683Z (over 1 year ago)
- Topics: bazel, bazel-rules, kustomize
- Language: Starlark
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rules_kustomization

A bazel macro for generating kustomize bases. The main motivation for this macro is to make it easy to use kustomize to
build manifests that can be used as k8s_deploy/k8s_object dependencies, etc.
It has been tested on OSX (amd64 and arm64) and Linux amd64. Other platform _may_ work.
## Setup
In your WORKSPACE file add the following:
```bzl
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_pseudomuto_rules_kustomization",
sha256 = "f25fecad8852572028e8f17080267dd915bbc6f258370ed6d4dccf4203159096",
strip_prefix = "rules_kustomization-0.1.0",
urls = ["https://github.com/pseudomuto/rules_kustomization/archive/v0.1.0.tar.gz"],
)
load("@com_pseudomuto_rules_kustomization//:workspace.bzl", "download_kustomize")
download_kustomize()
```
## Usage
Add the following to your BUILD file. This build file must be a sibling of kustomization.yaml. See the
[example](example) for a working demo.
```bzl
load("@com_pseudomuto_rules_kustomization//:defs.bzl", "kustomization")
kustomization(
name = "kustomization",
srcs = glob(["**/*.yaml"]),
)
```
This can then be used as input by other rules. For example:
```bzl
# ...omitted code from above
load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
k8s_deploy(
name = "crd",
template = ":kustomization", # the name from above
visibility = ["//visibility:public"],
)
```
### Viewing output
If you'd like to see what is being generated, you can run the `.manifest` rule. Assuming we have the kustomization
rule above you'd run `bazel run //:kustomization.manifest`. This will dump the result from `kustomize build` to
stdout.