GoogleContainerTools / GoogleContainerTools/skaffold
Feature Request: Support Bazel renderer for Kubernetes YAML
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
# Context
As a developer with a full bazel-ified monorepo (code and manifest generation together) it would have developer easier to have skaffold support rendering YAML from bazel directly.
Currently I work around this with by adding as many hooks to build the manifests as a I can to ensure they're up-to-date before the `rawYaml` renderer goes over them:
```yaml
apiVersion: skaffold/v4beta13
kind: Config
metadata:
name: k8s
build:
tagPolicy:
gitCommit:
variant: CommitSha
local:
useDockerCLI: false
useBuildkit: true
concurrency: 0
artifacts:
- image: service
bazel:
target: //go/cmd/service:container-tarball.tar
platforms:
- platform: linux/amd64
target: //build/platforms:linux_amd64
- platform: linux/arm64
target: //build/platforms:linux_arm64
hooks:
after:
- command: ['bazel', 'build', '--remote_download_toplevel', '//manifests/local/service', '//manifests/local:local-namespaces-manifests']
os: [darwin, linux]
manifests:
rawYaml:
- '../../../../build/bazel-out/darwin_arm64-fastbuild/bin/manifests/local/namespaces-manifests/*'
- '../../../../build/bazel-out/darwin_arm64-fastbuild/bin/manifests/local/service/manifests/*'
deploy:
kubectl:
hooks:
before:
- host:
command: ['bazel', 'build', '--remote_download_toplevel', '//manifests/local/service', '//manifests/local:local-namespaces-manifests']
os: [darwin, linux]
```
However this is unstable with needing to manage the directory traversal & build options (`darwin_arm64-fastbuild`) so this config ends up not being portable between machines.
# Feature Request
To support a [renderer](https://skaffold.dev/docs/renderers/) which takes a bazel target that outputs a directory (`TreeArtifact`) or a single YAML file then do the same processing as `rawYaml` over the file.
An example edit from the above config:
```yaml
apiVersion: skaffold/v4beta13
kind: Config
metadata:
name: k8s
build:
tagPolicy:
gitCommit:
variant: CommitSha
local:
useDockerCLI: false
useBuildkit: true
concurrency: 0
artifacts:
- image: service
bazel:
target: //go/cmd/service:container-tarball.tar
platforms:
- platform: linux/amd64
target: //build/platforms:linux_amd64
- platform: linux/arm64
target: //build/platforms:linux_arm64
manifests:
bazel:
targets:
- '//manifests/local:local-namespaces-manifests'
- '//manifests/local/service'
deploy:
kubectl: {}
```
The `//manifests/local:local-namespaces-manifests` and `//manifests/local/service` targets are produced by [`rules_jsonnet`](https://github.com/bazelbuild/rules_jsonnet/)'s `jsonnet_to_json` as a single file & directory respectfully.
Contributor guide
Assessment
This issue has not been assessed yet.