Add "enabledAPIs" to support selectively deploying package objects#2646
Add "enabledAPIs" to support selectively deploying package objects#2646ulucinar wants to merge 2 commits intocrossplane:masterfrom
Conversation
- Fixes crossplane#2122 Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
|
I'd like to understand more about the use cases behind this change before we proceed with it. I see in #2122 we discuss that it may help scope authz permissions for strategies like IRSA. I'm particularly curious how that would interplay with the ideas put forward in #2411. Would a user create multiple I also suspect that despite the above use case being what we have written down the more immediate motivation is that we're seeing issues scaling on number of CRDs. If that's really what this is solving for us today I'd like us to have an issue opened against crossplane/crossplane detailing it. I've heard us discuss potentially rate limiting CRD installs (to smooth out OpenAPI processing) and bumping REST mapper client rate limits as other options to alleviate this undocumented problem. Do we think this option is the better solution or is it a temporary workaround? |
…ubectl plugin Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
|
We decided to hold this functionality for now; per #2649 we're addressing the performance issues we've seen by working with the Kubernetes folks to improve performance there. That said, we may revisit something like this functionality in future. |
Description of your changes
Fixes #2649
This PR proposes a change that introduces the field
enabledAPIsfor both package and package revisions to support deploying package objects selectively. Each object contained in the package manifest is checked against the regular expressions provided in theenabledAPIslist. If no match is found, package object is not established and skipped. IfenabledAPIsis empty, then all objects are established.Changing the
enabledAPIslist results in a new package revision. However, duplicates are eliminated and the order of the regular expressions in theenabledAPIsdo not matter. Thus the following specifications are all the same and will not result in a package revision (and corresponds to the same package revision):. However, the following enabled APIs declaration belongs to a different package revision although with the current
provider-tf-azureit selects the same set of package objects:Each item of
enabledAPIsis a regular expression that's matched with a string representation of theschema.GVKof each package object. For this purpose, the package objects GVK is formatted as:For instance,
provider-tf-azuresv1alpha1.ResourceGroupkind's GVK is formatted as the following and then is matched against every element ofenabledAPIsif a non-zero valuedenabledAPIsis supplied:This allows us to define fine-grained selectors to include/exclude APIs.
Also in this scheme,
apiextensions.k8s.io/v1.CustomResourceDefinitions are treated in a special way. If the package object is a CRD, then it's not only the CRD that's matched against items inenabledAPIsbut also all versions of the defined kind by that CRD. This allows us, for example, to enable the wholevirtualAPI group inprovider-tf-azurewith a compact specification such asvirtualorvirtual.*.Active package revision is determined by the package image's digest and a stable digest computed from the value of the
enabledAPIsfield and not from the actual set of package objects selected. I think this is a good enough approximation for practical purposes and also reflects the usual behavior of similar APIs.This PR also changes the package revision name format if
enabledAPIsis non-empty. A hash computed from the set of enabled APIs is appended to the package revision name so that the new format is<package name>-<image hash>-<enabled APIs hash>. IfenabledAPIshas zero-length, then package revision format is still<package name>-<image hash>. Thus, Crossplane upgrade is not expected to affect existing provider installations unless the new API is explicitly used in thev1.Providerorv1.Configurationobject defining the package.Another important aspect of the changes proposed here is that the provider revision reconciler passes a new command-line option,
--enabled-apis, to the provider container (defined in the provider deployment corresponding to the revision) to communicate the enabled APIs, the provider is expected to honor this command-line option and add controllers only for the enabled APIs. It may fail if it does not properly handle the new command-line option, as any CRDs not selected by a non-zero valuedenabledAPIsfield will not have been registered via the package revision controller. Or it may fail because of being passed an unknown command-line option. Example manifest for a provider deployment whenenabledAPIshas a non-zero value is given in the "How has this code been tested" section. IfenabledAPIshas a zero-length, then provider revision controller does not produce the--enabled-apiscommand-line option thus the behavior is backwards-compatible if the new API is not employed.I have:
make reviewableto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
There are two additional PRs accompanying this one, in terrajet repo for generating the required code for properly handling the communicated set of enabled APIs and another one in
provider-tf-azurethat has been generated using the new terrajet version and that introduces the--enabled-apiscommand-line option to the provider. This PR has been manually tested with these three PRs using the following provider manifest. The package referred in this manifest has been built and pushed to the registry. I can also produce an amd64 version (or maybe one will have already been produced in the CI pipeline of the corresponding change) if requested:Here is the partial
statusof the correspondingv1.Providerobject when the above manifest is applied:Here is the corresponding (partial) provider revision manifest generated by the package revision controller:
Please note that CRDs not selected by
enabledAPIsare not available instatus.objectRefs.Here is the (partial) provider deployment corresponding to that revision: