bazelbuild / rules_k8s

This repository contains rules for interacting with Kubernetes configurations / clusters.
Apache License 2.0
291 stars 136 forks source link

k8s_object does not pass args when wrapped in k8s_objects #640

Open uhthomas opened 3 years ago

uhthomas commented 3 years ago

Given two k8s_objects

k8s_object(
    name = "some_object",
    args = ["-l=app.kubernetes.io/managed-by=some-repo"],
    context = "some-context",
    kind = "Deployment",
    template = "some_list.yaml",
    visibility = ["//visibility:public"],
)

k8s_object(
    name = "some_other_object",
    args = ["-l=app.kubernetes.io/managed-by=some-repo"],
    context = "some-other-context",
    kind = "Deployment",
    template = "some_other_list.yaml",
    visibility = ["//visibility:public"],
)

Applying each object individually produces the expected result:

$ /usr/bin/kubectl --kubeconfig= --cluster= --context=some-context --user= diff -l=app.kubernetes.io/managed-by=some-repo -f -

But, given they're wrapped in k8s_objects

k8s_objects(
    name = "objects",
    objects = [
        ":some_object",
        ":some_other_object",
    ],
)

The additional args go missing.

$ /usr/bin/kubectl --kubeconfig= --cluster= --context=some-context --user= diff -f -
$ /usr/bin/kubectl --kubeconfig= --cluster= --context=some-other-context --user= diff -f -
gonzojive commented 2 years ago

I don't know if this is the same issue, but it seems like it:

bazel run @io_bazel_rules_k8s//k8s/go/cmd/resolver -- --help

produces

....
  -allow_unused_images                                                                                                                  
        Allow images that don't appear in the JSON. This is useful when generating multiple SKUs of a k8s_object, only some of which us\
e a particular image.                                                                                                                   
  -image_chroot string                                                                                                                  
        The repository under which to chroot image references when publishing them.                                                     
  -image_spec value                                                                                                                     
        Associative lists of the constitutent elements of a docker image.                                                               
  -stamp-info-file value                                                                                                                
        One or more Bazel stamp info files.                                                                                             
  -substitutions string                                                                                                                 
        A file with a list of substitutions that were made in the YAML template. Any stamp values that appear are stamped by the resolv\
er.                                                                                                                                     
  -template string                                                                                                                      
        The k8s YAML template file to resolve. 
bazel run //web/cmd/hello_world_server:dev.resolve -- --help

seems to ignore the flags

load("@k8s_deploy//:defaults.bzl", "k8s_deploy")

# See
# https://github.com/bazelbuild/rules_k8s/blob/master/examples/hellohttp/go/BUILD
# for an example.
k8s_deploy(
  name = "dev",
  template = ":deployment.yaml",
  # An optional collection of docker_build images to publish
  # when this target is bazel run.  The digest of the published
  # image is substituted as a part of the resolution process.
  images = {
    "hello-http-image:latest": ":image"
  },
)