Skip to content

Feature Request: Support Bazel renderer for Kubernetes YAML #9979

@dbanetto

Description

@dbanetto

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:

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 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:

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's jsonnet_to_json as a single file & directory respectfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions