kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
11.09k stars 2.26k forks source link

Add verbose and/or debug logging to kustomize command #5536

Open erinaceous opened 9 months ago

erinaceous commented 9 months ago

Eschewed features

What would you like to have added?

As per the advice given in the original issue, this is a feature request for incorporating verbose or debug log output when running kustomize CLI commands:

Perhaps some variation on:

Which would, given varying levels of implementation complexity:

A good entry-point would be kustomize build specifically, logging what bases/resources are being read, and then logging the transformations being applied (in order they were applied), implicitly showing the order in which they're being applied to produce the final set of kubernetes resources.

Is this big enough to warrant a KEP? Honestly, I don't know enough to know if it does!

Why is this needed?

When kustomize is attempting to resolve bases it is helpful to find out what is going on.

I would also like to see this functionality, after spending an embarrassing amount of time using manual trial and error to figure out why Kustomize wasn't rendering the objects the way I expected. There's literally no feedback in this tool and it makes it pretty hostile to users.

Can we add some kind of tracing/debugging functionality (e.g. via a CLI option) that steps through the transformations in detail? For example, logs the before and after structs for each transformation and where in the code the transformation is occurring?

Like, --debug to turn on logging like DEBUG: Fetching URL https://blah.com/blah.yaml.

Given the complexity implied by importing bases and the absolute opacity in which this is done, a --verbose or --debug flag, as most developer tools have, seems like a natural feature.

Without that, it's hard to scale this to be used by developers who aren't familiar with kustomize, since there's at best a vague hint as to where they should look to find the origin of particular lines.

Can you accomplish the motivating task without this feature, and if so, how?

With difficulty:

an embarrassing amount of time using manual trial and error

What other solutions have you considered?

As an end-user, and somebody not familiar with Go, I would not really have any alternative, bar "trial and error until kustomize does what I expected it to do based on the documentation and examples I've read".

As someone who likes to tinker, if I had enough time I'd probably learn enough to step through running kustomize build in GDB...

Anything else we should know?

I appreciate that despite this appearing a simple request, it could potentially touch a lot of this codebase, as for it to be useful to end-users and extension developers, would require retroactively adding logging calls across a lot of stuff, having identified where it would be useful..!

I also appreciate whilst writing this out as a feature request that just adequately describing the feature is actually quite a big and time-consuming thing..! I will re-visit this when I can, and perhaps others who commented on the original issue could weigh in on:

I'm not interested in owning the feature per se, but definitely happy to contribute should someone else start the PR.

Feature ownership

koba1t commented 9 months ago

Hi @erinaceous I believe it's an interesting feature and helpful debug. I think this feature needs to be rewritten on many points, and the internal interface needs too.

If we implement this feature, we need to write KEP before starting implementation.

/triage under-consideration

k8s-triage-robot commented 5 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 4 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

LarsStegman commented 4 months ago

/remove-lifecycle rotten

k8s-triage-robot commented 1 month ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

LarsStegman commented 1 month ago

/remove-lifecycle stale