-
Notifications
You must be signed in to change notification settings - Fork 946
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
Proposal: Custom Compositions #2524
Comments
|
Following up with some more thoughts: ---
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: CustomComposition
metadata:
name: example
spec:
compositeTypeRef:
apiVersion: database.example.org/v1alpha1
kind: CompositePostgreSQLInstance
# Take an array of functions so that we can stack/pipe functions.
functions:
- image: crossplane/example-helm-chart-composition:v1We could also potentially use the |
|
Disclaimer: I've only been using Crossplane for a couple of days so I might get some things wrong here, but I thought I'd give my 2 cents on this matter. I have a work-in-progress operator that is 90% composing resources and generating sensible statuses, and this is of course what Crossplane does really well so I'm considering adopting it. My initial expectation was that Crossplane might not provide everything I need but I'd be able to extend it where necessary. But despite my fairly basic requirements, I'm hitting some roadblocks that only seem solvable through a custom provider or controller that templates other provider resources for me, which doesn't play well with how compositions work and would make switching to Crossplane nonsensical altogether. One example is that I need to accommodate various helm charts and there are no standardized formats for secrets etc in helm land. Configuring a helm chart with a database user from I think custom compositions are best thought of as an escape hatch, where you might not want to use it if you don't have to, but when you do it's because there are not other options. Being able to solve problems you don't yet know you are going to have is extremely valuable. Some thoughts on the design:
spec:
functions:
- image: crossplane/example-helm-chart-composition:v1
functionConfig:
# apiserver resource
foo:
from:
name: foo-resource
namespace: example
kind: Foo
# static value
bar:
value: "bar"
spec:
resources:
- name: db-role
# ...
- name: helm-release
functions:
- image: helm-only
# ...
functions:
- image: all-resourcesThe execution order in this example being:
Wouldn't we be able to do the same with
Alternative suggestion, assuming the list is guaranteed to be ordered: The first item is the XR, the rest are resources. Or that plus the annotation. |
|
Slightly related, #2110 is also about customizing composition behavior but at a lower level that won't require you to give up using |
|
I'm adding this to the v1.7 release, which is due EOM. It's perhaps a little bit of a stretch to have an alpha implementation by that time, but I think it's possible. |
|
A few people asked in Slack, here is the old design doc for custom composition #1705 |
|
It might be interesting to check how
example for kustomize: https://youtu.be/YlFUv4F5PYc?t=1361 |
It was recently bought to my attention that v1.7 was accidentally slated for late March when it should actually be early March, so I'm going to remove this from v1.7. I think that's a bit aggressive. |
See crossplane#2524 Signed-off-by: Nic Cope <negz@rk0n.org>
|
Hey folks! A few of us have started meeting to discuss this effort each week on Tuesdays at 9pm PST. If you’re interested in joining in and helping out please let me know and I’ll add you to the meeting invite. Our agenda and notes are at https://docs.google.com/document/d/1n8018YaDXCl_6E8y9J5untSZ4rH811dL75GPnERRQxA/edit#. Edit: PS you can find us in #sig-custom-compositions on Crossplane Slack, too. :) |
|
Breadcrumbs to kptdev/kpt#2567, which discusses alternatives to containers as ways to run KRM functions. |
See crossplane#2524 Signed-off-by: Nic Cope <negz@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
|
Could I add my 2 cents here, and with the current draft you will end up making Crossplane turing complete at what cost? Every templating tool that has introduced constructs like this has had it misused and set some poor standards which make it harder for the eco system to stay simple and easy to use. Please dont recreate DAGs or functions in YAML. That's already been done. |
|
Hey all! We've started using Compositions as a key component for our cell-based architecture and there's a few things we're running into that I don't see simple solutions to today:
If I think of anything else I'll chime back in here, I'm really excited about the upcoming functionality! |
|
Sorry if this question has already been addressed, why couldn't we just expand on composition and just add these as yaml preprocessing ? |
|
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as |
|
/fresh |
Fixes crossplane#3001 Fixes crossplane#2959 Fixes crossplane#2958 This commit adds a design document for 'Composition Functions', which we've previously referred to as 'Custom Compositions'. See crossplane#2524 for the full context. This is the Signed-off-by: Nic Cope <nicc@rk0n.org>
|
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as |
|
/fresh |
|
/fresh |
|
@libracoder Composition Functions (formerly called Custom Compositions) were released in v1.11 and are available to try out today! Check out this guide in the docs: https://docs.crossplane.io/knowledge-base/guides/composition-functions/ |
|
Thank you @jbw976 |
What problem are you facing?
Composition is the Crossplane feature that lets teams define their own opinionated APIs (i.e. Kubernetes CRs). We call these APIs "Composite Resources", or XRs for short. When a user creates an XR, Crossplane uses another kind of resource - a
Composition- to determine what to do. For example aCompositionmight tell Crossplane that when a user creates anAcmeCoDatabaseXR it should respond by creating a GCPCloudSQLInstanceand aServiceAccount. From our terminology documentation:A Crossplane
Compositionconsists of an array of one ore more 'base' resources. Each of these resources can be 'patched' with values derived from the XR. The functionality enabled by aCompositionis intentionally limited - for example there is no support for conditionals (e.g. only create this resource if the following conditions are met) or iteration (e.g. create N of the following resource, where N is derived from an XR field). These limits:Compositiontype to be relatively simple, avoiding it becoming a programming language expressed as YAML.Limiting the functionality of our
Compositiontype allows us to reduce Crossplane's learning curve and implementation complexity. At the same time it limits Crossplane's ability to address certain use cases. It's not uncommon for Crossplane users to resort to 'composing' Crossplane managed resources using more featureful tools such as Helm or jsonnet when they hit the limitations imposed by theCompositiontype. Furthermore, some Crossplane users simply prefer to express their intent in a language (or with a tool) they already know and feel comfortable with, such as Helm, jsonnet, Python, HCL, Typescript, etc.How could Crossplane help solve your problem?
Crossplane could allow users to express "composition logic" using a tool of their choice. While it's true that users could simply use Helm, jsonnet, etc etc to compose Crossplane managed resources into higher level abstractions (like the aforementioned
AcmeCoDatabaseexample), we feel that these abstractions are best exposed as APIs, not as client-side constructs.Exposing abstractions as a (Kubernetes) API:
Crossplane could support users with advanced composition requirements (or existing tooling preferences) by supporting a "server side" BYO tooling approach to composition logic. The Crossplane maintainers typically refer to this idea as "Custom Composition".
With Custom Composition most of Crossplane's Composition machinery (XRDs, XRs, claims, etc) would remain in place, but the
Compositiontype would be replaced by pluggable logic. A Custom Composition might look something like the following:The idea here is that composition logic would be implemented by an arbitrary OCI container. The container would accept a valid Crossplane XR as its (stdin) input, and output (to stdout) a (possibly mutated) version of the input XR, plus one or more valid composed Crossplane resources. This is not unlike the approach taken by KRM functions (which we may consider reusing).
Note that the name
CustomCompositionis not fixed, and in fact we may want to add this functionality to the existingCompositiontype such that users could choose between supplying an image or an array of resources and patches. The key reason to start with a distinct type is that it gives us the ability to introduce functionality at v1alpha1, and thus make breaking changes.Some prior art on this topic:
The text was updated successfully, but these errors were encountered: