vmware-archive / kubecfg

A tool for managing complex enterprise Kubernetes environments as code.
Apache License 2.0
727 stars 62 forks source link

filter on kubecfg update #241

Open bigdrum opened 5 years ago

bigdrum commented 5 years ago

Feature request:

It would nice to add flag to kubecfg update so that only apply update to a subset of object that match the filter (regex match for name, for example).

I have a single file defines multiple deployments, sometimes I want to update a subset of it to try out the change, before applying to all.

mkmik commented 5 years ago

I was thinking to add support for using a label selector; wdyt?

jjo commented 5 years ago

I was thinking to add support for using a label selector; wdyt?

it would be really useful to also be able to subset by kind and/or metadata.name (/ namespace).

mkmik commented 5 years ago

what about (also) limiting by subtree with a dot separated "path"?

jjo commented 5 years ago

the dot-separation is an interesting and tricky one also, because it depends if you viewed it from the Kubernetes hierarchy[1] or DNS (sp for Services)[2] PoV.

I.e. the pairs below may represent the same object to diff people:

Maybe a '/' instead? which then hints on globbing for matching, while I (personally) have a strong preference for regex'ing.

mkmik commented 5 years ago

I was thinking it in terms of a "jsonnet path" inside the sources. People will group related objects together anyway and kubecfg looks for objects at arbitrary depths

anguslees commented 5 years ago

Fwiw: #16 is almost a duplicate, except the motivation is the show subcommand.

Re above: I think picking a jsonnet (json) subtree would be super useful, particularly for debugging via show. It assumes we only have a single jsonnet top-level file, which is theoretically not true - so we need to solve that somehow (perhaps ignore files that don't contain the given json path).

Given the radically different (and all desirable) proposals above, I think we need to consider the command line UX carefully, and ensure it is possible to extend it to multiple query syntaxes, and apply it to update/show/diff/etc. This might just be as simple as building a family of command line options, that follow some sort of similar pattern (eg: --select-by-labels).

A separate but important consideration: We will want to force update --skip-gc=true (or abort if =false) in the presence of a filter.

bigdrum commented 5 years ago

From me, regex to select namespace, kind, and name (as @jjo mentioned) would be most straightforward and easy to reason about.

Selecting on subtree of jsonnet might be confusing/dangerous on update (it might make sense for show). Since it highly ties to the structure of the jsonnet, which can be changed by refactoring, and there is also a learning curve on it (this reminds me of https://tools.ietf.org/html/rfc6901).