-
Notifications
You must be signed in to change notification settings - Fork 227
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
Porch: PackageVariant Redux #3973
Comments
Maybe PackageVariantContext iso injection (just an idea, as I am thinking of it as providing context to how we want to consume the package for this use case). It would also be nice to have this capability for offline use (meaning just with kpt). We have scenarios where we have a common package we want to be able to use before porch kick(s). E.g. creating repositories for porch where with some PackageVariantContext we can leverage the same package in different ways. E.g. have a regular repo a staging repo, etc. |
I'm trying to avoid package-specific APIs. The idea of injection is to allow the package to advertise how it can be configured. Another term @justinsb used for a similar concept is "binding" - so, the package has binding points you can "attach" a resource to. In that case he was dealing more with "binding" two packages together, rather than "injecting" from the cluster. These are similar concepts we may want to unite in some way, but I do think the distinction between "binding packages via an interface" and "injecting config from the cluster via an interface" are subtly different. |
Yes agree I was not implying package-specific APIs. The thought is to leverage some of this in a semi offline fashion. The way I see it this allows to provide specific context to the package. Whether it is through another package or via a CR/KRM resource are all options |
Extending the idea above, we can also allow it to inject resources from other packages, encompassing the "binding" concept. So, it would look something like:
Omitting the There are some details to work out. When we know the binding point, we know the GVK; maybe we should make it optional across the different types of injections. For the package one, we have namespaces for the repo/package and for the resource inside it, so we may want to create separate structures. In general a few more iterations on the API for usability would be useful, but I think this is better than what we have. |
Oh, I misunderstood your PackageVariantContext thing - you were suggesting the naming instead of |
Also, in Nephio we found a need to inject multiple resources of the same type. For example, we use a sentinel CR to represent a demand for a certain set of resources; we then inject that resource from other packages. Something like what is described here (though the actual implementation is a little different): https://github.com/nephio-project/nephio/pull/263/files I think we could extend the concept described here to manage this type of dependency as well. At least, it's worth discussing if that belongs here or as a separate post-fanout controller (aka "specializer" in Nephio terminology). |
Another point on this, "context" here makes sense in some cases, but I wonder if there are other cases that are a slightly different idea. Things like the cluster the package is going to, the region, dev/test/stage/prod all make sense as "context". But there are other things, like "configure the capacity of this UPF". It's not really about adjusting the workload to the context it is running in, but more about what we want out of the workload itself. I am not sure this matters at all, but I am trying to tease apart the types of configuration APIs that a package may advertise, and whether there is a meaningful pattern as to how, when (in the overall provisioning process), and by whom they are used. |
Another way to think about this, after a discussion with @liamfallon is to use an analogy to programming. You can think of each binding point name as a variable name. The package author is declaring a sort of function signature - you can set this variable (binding point) to a value of this type (GVK). The PV is like calling the function - you are deciding which values to assign to the variables. In this updated design, PV allows you to take the values from the cluster, from another package, or set them to a literal value. Similarly, each variable (binding point) can be required or optional. Optional ones take the default values if not set. The key points are:
|
Another thought based on @tliron's tko demo: should we allow (at least) the "direct" binding to be a patch as opposed to a complete resource? This allows more flexibility around defaulting. In fact today "injection" is effectively a "patch" of the entire spec...so maybe there's something more general there. See also #3121 (I need to read that one thoroughly too...I think there are some gotchas in here). |
that's an interesting idea - could PV, or some kernel of PV, live in a package and be resolved client-side? It's a bit of a tangent, but in general, I'd like to move towards APIs that can be resolved by different tools. So, for example, instead of embedding upstream information in the Kptfile, we would create an "Upstream" resource that lives in the package. It could be processed client-side by kpt, or server-side by Porch. In time, this would become a collection of package-oriented APIs that even other config tools could support. This also raises the idea of whether our current PackageRevisionResources is the right model for mapping package contents into K8s APIs. I would prefer something that makes those more "real" in the server, but of course without any actuation mechanism. This is a bigger discussion I am digressing into...I'll try to write up some thoughts in a design proposal soon. |
Have been looking a bit deeper into this and looking at the pipeline changes. What would be a good capability to have here is what the intention was with package-context but apply this to a new resource and use cel-functions to set the values of the parameters. E.g.
|
Also on the clusterResourceBinding point would we not use ?
|
We have been working with the PackageVariant resource for the last couple weeks in Nephio. Functionally, we're probably OK (apart from bugs which I will work on), but I think a few improvements are warranted. Some issues:
injectors
mechanism is awkward. It is designed with the idea that the common use case would be "match all GVKs in the cluster with this name, and associate them to injection points by GVK". But I don't think that's the right model; I think the right model is "I have these injection points, how should I satisfy them". In other words, "this package supports these configuration APIs, how should I set the values". Currently it also means that you can not inject multiple resources of the same GVK; only a single instance per GVK is allowed (well, others are allowed but they will all receive the same values).When PackageVariantSet generates PackageVariants, it uses hash-based naming. This can cause issues because we use the PackageVariant name as part of the function name in the pipeline.(fixed in Change PV naming and fix pointer bug #3986)I think 1, 2, and 3 can all be addressed with a simplified injection mechanism that works as follows.
I think this satisfies nearly all, if not all, the original use cases of injection and package context manipulation, but in a more easily understandable way.
I would add this as a new field in PackageVariant, so we would have all the mechanisms available for a while, but the plan would be to mark
packageContext
andinjectors
as deprecated and replaced by this (maybeinjection
?).For 4), I think we can solve this with a(this probably is not needed with the fix made in #3986)functionQualifier
string in thePipelineTemplate
. For PV, we would default this to the PV name, so this is totally backward compatible. For PVS, we would set this to the PVS name by default, but also allow the user to specify it like other fields in the PackageVariantTemplate.cc @henderiw @natasha41575 @mortent @SimonTheLeg
The text was updated successfully, but these errors were encountered: