-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layering of templated yaml guidance #938
Comments
@100mik is looking into it, will get back to you soon |
Hey Carvel friends! 👋 I was chomping down on my breakfast and (who knows how) I stumbled onto this issue. I hope you don't mind, but I couldn't stop myself from taking a run at this... for old times' sake. I hope you all are doing well!!! Hey @eriknelson, FWIW, I dropped a PR on your repo with a suggested approach: eriknelson/ytt-debug#1 If I understand your needs well, it goes a long way to showing how you might use If you're happy living in the Makefile world, this kind of approach might just do it for you. Also, ICYMI, these resources can helpful in making heads-or-tails about how ytt functions and composes:
|
@jtigger really kind of you! I will take a look later on when I have a chance, incredibly helpful answer! |
Seems like I can't get enough... I included another PR which takes a more "ytt-to-the-max" approach: eriknelson/ytt-debug#2 It's far more complicated, but it uses the full power of |
Use Case
I'm working to build several different LXC based container images, which are
defined with a yaml spec. Becuase I'll have a library of these images, often
with a lot of shared configuration, I need a solution for building this shared
library and the ultimate manifests while keeping things DRY. I'm used to
kustomize and other templating solutions, but the real need here is just yaml,
and I need something more sophisticated than yq. ytt looks like it is perfect
for my needs.
Current layout
Project that is stripped down to the core elements of the question with a
reproducible case.
link
make coredns-manifest
is what I'm hoping to be my complete target.make _base-manifest
&make _common-manifest
will each compile yaml fragmentsof each layer independently.
Templates
I'm having some trouble groking the idiomatic means of doing this with ytt
and determining what the correct features would be to use to accomplish this
(functions, modules, templates, or overlays)?
This is not an issue that really has anything to do with distrobuilder, so
anything to do with that is generally out of scope for this issue. Here's
how I'm thinking about it:
base of the image. The schema of its specification is the same, but the values
differ, so I believe this is a natural fit for schema+values files, and
templating.
just my preference for working inside of the container, maybe I have some
scripts I want to install etc.
of the image, usually configuration and the specific package. CoreDNS falls
into this bucket.
As i"m putting this together, each layer is probably going to have templated
fields that I'd like to keep in a values file, and verify with a values
schema file. Each layer ends up being composed of a schema + values + template
file. Each of these can, and should get rendered independent of one
another. A lower layer shouldn't have any knowledge of layers that will
be overlayed on top of it.
Overlays
The ultimate file is a composition of these layers on top of one another,
ultimately ending up at the final image definition. I'd like to be able to
overlay them with descending precedence:
workload > common > base
I will also need the ability to annotate my desired merging behavior sometimes
on an array node basis, i.e. concat array items, concat array items but drop
any duplication (this is effectively a set) etc.
Problems & Questions
to "fight the framework", so I'd like to do this in the idiomatic ytt manner.
the command; should I be passing all schemas in order, then all values, then
all the templates, or should I be passing schema > values > template in order
of each layer?
"triplicate" in order of least specific to most specific. I'm running into
the following error with this approach:
The details are in the linked project, but I suspect the issue here is it's
trying to apply the aggregation of all the schemas first, and because the
distro.yml
file has none of the nodes that thecommon.yml
schema declaresit's producing the error. I'm not sure about this though since the error
is really quite opaque. I'm also not certain I have a grasp over the ytt
fundamentals at a depth that's required to accomplish what I'm trying to do.
However, as mentioned before, there's no reason that I should have higher layers
bleed their information into lower layers; the entire point is for a lower
layer to have no knowledge over what's getting layered on top of it.
I'm 99% sure that ytt is the right tool for this job, I'm just hitting a wall
trying to wrap my head around the "right" manner to do it. Is someone able
to point me in the right direction? TYIA.
The text was updated successfully, but these errors were encountered: