Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ bazel_dep(name = "rules_img", version = "0.3.13")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "rules_go", version = "0.54.0")
bazel_dep(name = "rules_shell", version = "0.8.0")
bazel_dep(name = "yq.bzl", version = "0.3.6")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.9")
Expand Down
88 changes: 88 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Bazel GitOps Rules is an alternative to [rules_k8s](https://github.com/bazelbuil
## Rules

* [k8s_deploy](#k8s_deploy)
* [cloudrun_deploy](#cloudrun_deploy)
* [k8s_test_setup](#k8s_test_setup)


Expand Down Expand Up @@ -96,6 +97,23 @@ When you run `bazel run ///helloworld:mynamespace.apply`, it applies this file i
| ***visibility*** | [Default_visibility](https://docs.bazel.build/versions/master/be/functions.html#package.default_visibility) | Changes the visibility of all rules generated by this macro. See [Bazel docs on visibility](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes).


<a name="cloudrun_deploy"></a>
## cloudrun_deploy

The `cloudrun_deploy` macro creates targets for deploying Knative Services to Google Cloud Run. It is defined in [cloudrun.bzl](./gitops/cloudrun.bzl) and is loaded via `load("@rules_gitops//gitops:defs.bzl", "cloudrun_deploy")`.

Similar to `k8s_deploy`, it uses kustomize to render the Knative Service manifest.
When you run a `.apply` target, it deploys the service by running `gcloud run services replace`.
When you run a `.delete` target, it deletes the service by running `gcloud run services delete`.
When you run a `.gitops` target, it copies the rendered manifest to the location `cloud/{project}/{region}/{name}.yaml` inside the deployment repository.

It accepts similar parameters to `k8s_deploy`, with the following differences:
- ***project*** (instead of `namespace`): The GCP project ID. This is also automatically set as the `namespace` field in the Knative Service YAML.
- ***region*** (instead of `cluster`): The GCP region (e.g. `us-central1`).

Note: There is no `service` parameter. The service name is dynamically resolved at runtime from `metadata.name` inside the rendered manifest.


<a name="base-manifests-and-overlays"></a>
### Base Manifests and Overlays

Expand Down
5 changes: 4 additions & 1 deletion gitops/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ load("//gitops/private:kustomize_toolchain.bzl", "current_kustomize_toolchain")

package(default_visibility = ["//visibility:public"])

exports_files(["create_gitops_prs.tpl.sh"])
exports_files([
"create_gitops_prs.tpl.sh",
"cloudrun.sh.tpl",
])

toolchain_type(
name = "kustomize_toolchain_type",
Expand Down
Loading