Created
October 5, 2022 03:56
-
-
Save negz/c5a5b4f82b06882906b08af377a609a4 to your computer and use it in GitHub Desktop.
Crossplane Composition Functions IO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apiextensions.crossplane.io/v1alpha1 | |
kind: FunctionIO | |
# Optional arbitrary KRM-like resource. Each function in a pipeline will be | |
# called with its own function config (i.e. config is not pipelined). | |
config: | |
apiVersion: database.example.org/v1alpha1 | |
kind: Config | |
metadata: | |
name: cloudsql | |
spec: | |
version: POSTGRES_9_6 | |
# The composite resource (including metadata, spec, and status) | |
composite: | |
apiVersion: database.example.org/v1alpha1 | |
kind: XPostgreSQLInstance | |
metadata: | |
name: my-db | |
spec: | |
parameters: | |
storageGB: 20 | |
compositionSelector: | |
matchLabels: | |
provider: gcp | |
writeConnectionSecretToRef: | |
name: db-conn | |
# TODO(negz): What if we just took the resources array of a Composition, | |
# including patches etc? Is there value in that? Code could just ignore patches | |
# and return fully formed bases if it wanted to. I like that this would make | |
# the data structure identical to a Composition resources array, but is there | |
# any other value? Would it be limiting to try to keep them identical? (Probably yes.) | |
resources: | |
- name: cloudsqlinstance | |
base: | |
apiVersion: database.gcp.crossplane.io/v1beta1 | |
kind: CloudSQLInstance | |
metadata: | |
name: cloudsqlpostgresql | |
spec: | |
forProvider: | |
databaseVersion: POSTGRES_9_6 | |
region: us-central1 | |
settings: | |
tier: db-custom-1-3840 | |
dataDiskType: PD_SSD | |
dataDiskSizeGb: 20 | |
writeConnectionSecretToRef: | |
namespace: crossplane-system | |
name: cloudsqlpostgresql-conn | |
connectionDetails: | |
- name: hostname | |
fromConnectionSecretKey: hostname | |
# TODO(negz): Do we want readiness checks too? Should the function be able to | |
# write to the status of the XR directly to set a status? | |
results: | |
- severity: Error | |
message: "Could not render Database.postgresql.crossplane.io/v1alpha1` |
@turkenh I ended up pushing a commit to crossplane/crossplane#2886 that adopts a stripped down version of the FunctionIO
API. I'd like to roll this conversation into that PR - I'll respond to your latest comment there. Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would be worried that this might result in more complicated helm charts, either long FunctionIO yamls or more advanced templating. Also by not being as intuitive, this might have a negative affect on adoption.
I agree that the former is more important and not sure whether the latter should be in scope at all since existing helm charts does not produce managed resources which would mean crossplane to deploy arbitrary resources on control plane. My concern is more around UX as I mentioned above.
Yes, it is definitely not great.
Actually I am wondering if we need to pass this
connectionDetails
field at all? If we want to pass existing connection secrets as input and expect XR connection secret as output (as we discussed in a separate thread), I believe outputting the final XR secret should be enough.