-
Notifications
You must be signed in to change notification settings - Fork 99
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
Adds support for extension custom manifests #468
Adds support for extension custom manifests #468
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skonto: 0 warnings.
In response to this:
Proposed Changes
- Appends manifests defined in the controller extension into the main manifested loaded by the controller.
- Why?
Currently downstream we have a scenario where a number of custom monitoring resources are installed along with the
core Serving ones. Although we can ship them together with the core ones, we would like to be able to create
a number of manifests dynamically from a resource blueprint as there is a lot of repetition in the monitoring custom resources.
Another issue is that we need to filter core resources to apply specific transformations and this requires special transformation where we need to pick a resource based on some naming convention.- Custom resources go through the validation process along with the rest of the manifests as usual assuming the appropriate label is defined.
- Although there is support for custom manifests at the CRD level this does not really fit into our requirements for platform specific custom resources. Afaik, that functionality was meant for loading manifests from a Knative user perspective eg. ops persona. This patch refers to the vendor persona.
/cc @markusthoemmes
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Welcome @skonto! It looks like this is your first PR to knative/operator 🎉 |
Hi @skonto. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/reconciler/common/extensions.go
Outdated
@@ -39,6 +40,9 @@ func NoExtension(context.Context) Extension { | |||
|
|||
type nilExtension struct{} | |||
|
|||
func (nilExtension) Manifests() []mf.Manifest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this take the KComponent to be able to dynamically decide based on Spec settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good idea does not hurt anything to add it.
func (t TestExtension) Manifests() []mf.Manifest { | ||
manifest, err := mf.NewManifest("testdata/kodata/additional-manifests/additional-sa.yaml") | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we should be able to return the error in case we want to abort.
/ok-to-test |
@houshengbo hi, from a ux perspective and given the number of platform specific yaml files to maintain it is not. My scenario is not about exposing extra manifests which are accessed by some url etc. I dont want these files exposed, to be part of the crd contract. I have already mentioned why from my point of view it is not a repititon in the description. Btw from a vendor perspective this PR adds to the existing stuff. |
@@ -26,6 +26,14 @@ import ( | |||
|
|||
type TestExtension string | |||
|
|||
func (t TestExtension) Manifests(v1alpha1.KComponent) ([]mf.Manifest, error) { | |||
manifest, err := mf.NewManifest("testdata/kodata/additional-manifests/additional-sa.yaml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in my custom extension, I can add new custom manifests by calling this. Only on code, right? not via Yaml?
Should we document that? Or at least capture this as a docs issue? Happy to help - I already have a use-case for this feature ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matzew there is already a way to add custom manifests via the CRD (yaml) check @houshengbo pointers above ;)
If you want to add the manifests via code without letting them being exposed to the user (so they cannot be subject to illegal change) you can do it with this PR. What else should we allow here? Do you have any pointers for the documentation? Feel free to add whatever you think would be useful ;)
+1 that's exactly what I want! /lgtm leaving approval to others |
@skonto Are you leveraging the capability of the platform-specific extension? |
@houshengbo yes check my link in the description, my plan is to create all the service monitor resources via a blueprint that is loaded from a local path and create the manifests dynamically by defining that |
@@ -109,7 +109,11 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1alpha1.KnativeServ | |||
common.CheckDeployments, | |||
common.DeleteObsoleteResources(ctx, ks, r.installed), | |||
} | |||
manifest := r.manifest.Append() | |||
platformManifests, err := r.extension.Manifests(ks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skonto plz update your local source code and do a rebase.
Your code is surely obsolete for now.
Another remark: as in the stages, we load the core manifests first, then the ingress manifests(you should have them after the rebase). And probably the extended manifests. It is order-critical. The one loaded first will be applied first, the one loaded in the end will overwrite the same ones before.
The question is if we want to make sure the extended manifest go over the core, we need to load them in the order: core first, ingress manifest second, and lastly the extended manifest.
But for the logic in this PR, it seems to be extended manifest first, core second... Considering changing the order.
You can create a function similar to common.AppendTarget
for extension, and add it in the stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (r *Reconciler) appendExtension(ctx context.Context, manifest *mf.Manifest, instance v1alpha1.KComponent) error {
platformManifests, err := r.extension.Manifests(instance)
if err != nil {
return err
}
*manifest = manifest.Append(platformManifests)
return nil
}
stages := common.Stages{
common.AppendTarget,
ingress.AppendTargetIngresses,
r.filterDisabledIngresses,
r.appendExtension,
r.transform,
common.Install,
common.CheckDeployments,
common.DeleteObsoleteResources(ctx, ks, r.installed),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @houshengbo will take a look.
@@ -106,7 +106,11 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1alpha1.KnativeEven | |||
common.CheckDeployments, | |||
common.DeleteObsoleteResources(ctx, ke, r.installed), | |||
} | |||
manifest := r.manifest.Append() | |||
platformManifests, err := r.extension.Manifests(ke) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz check my comment below for the serving. it applies here as well.
c89398c
to
83dca46
Compare
/hold |
/unhold |
@@ -108,6 +108,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1alpha1.KnativeServ | |||
common.AppendTarget, | |||
ingress.AppendTargetIngresses, | |||
r.filterDisabledIngresses, | |||
r.appendExtension, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we name it appendExtensionManifests
or the like?
We can do that in a different PR, but just wondering, since it's not appending the extension at whole, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok .
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: matzew, skonto The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Proposed Changes
Currently downstream we have a scenario where a number of custom monitoring resources are installed along with the
core Serving ones. Although we can ship them together with the core ones, we would like to be able to create
a number of manifests dynamically from a resource blueprint as there is a lot of repetition in the monitoring custom resources.
Another issue is that we need to filter core resources to apply specific transformations and this requires special transformation where we need to pick a resource based on some naming convention.
/cc @markusthoemmes