Skip to content
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

Merged
merged 6 commits into from
Feb 17, 2021

Conversation

skonto
Copy link
Contributor

@skonto skonto commented Feb 12, 2021

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 serves the vendor persona.

/cc @markusthoemmes

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Feb 12, 2021
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 12, 2021
@skonto skonto changed the title Adds support for custom manifests Adds support for extension custom manifests Feb 12, 2021
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a 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.

@knative-prow-robot
Copy link
Contributor

Welcome @skonto! It looks like this is your first PR to knative/operator 🎉

@knative-prow-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 12, 2021
@@ -39,6 +40,9 @@ func NoExtension(context.Context) Extension {

type nilExtension struct{}

func (nilExtension) Manifests() []mf.Manifest {
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

@houshengbo
Copy link
Contributor

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 12, 2021
@houshengbo
Copy link
Contributor

#374
#379
@skonto
I have added the support to specify the additional manifests.
Isn't it this PR a repetition?

@skonto
Copy link
Contributor Author

skonto commented Feb 12, 2021

@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")
Copy link
Member

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 ;-)

Copy link
Contributor Author

@skonto skonto Feb 15, 2021

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 ;)

@matzew
Copy link
Member

matzew commented Feb 15, 2021

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.

+1 that's exactly what I want!

/lgtm

leaving approval to others

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 15, 2021
@houshengbo
Copy link
Contributor

@skonto Are you leveraging the capability of the platform-specific extension?
Do you have an example of how to use this capability?
Knative lacks of docs on that aspect.

@skonto
Copy link
Contributor Author

skonto commented Feb 15, 2021

@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 manifests function like in the transform case.

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor

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),
	}

Copy link
Contributor Author

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)
Copy link
Contributor

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.

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2021
@skonto
Copy link
Contributor Author

skonto commented Feb 17, 2021

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 17, 2021
@skonto
Copy link
Contributor Author

skonto commented Feb 17, 2021

/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 17, 2021
@@ -108,6 +108,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1alpha1.KnativeServ
common.AppendTarget,
ingress.AppendTargetIngresses,
r.filterDisabledIngresses,
r.appendExtension,
Copy link
Member

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok .

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/common/extensions.go 100.0% 80.0% -20.0

Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2021
@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 17, 2021
@knative-prow-robot knative-prow-robot merged commit 353589d into knative:master Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants