provider-kubernetes icon indicating copy to clipboard operation
provider-kubernetes copied to clipboard

Dependencies between resources

Open jonnylangefeld opened this issue 4 years ago • 3 comments

It is often necessary to declare dependencies between resources in a composition. Some default crossplane cloud providers have dependencies between specific resources. The crossplane docs contain an example of a MySQL managed resource that depends on a resource group. The resource group reference fields are implemented in the manifest of the MySQLServer managed resource.

However for the kubernetes provider we would need a more arbitrary resource dependency declaration on the Object, because we don't know what the resource actually is. Maybe a dependsOn array of objects with resource references defined by group, version, kind, name and namespace. The dependsOn property should be a sibling to the manifest property. Only once status.condition named Ready is true for all referenced resource, the resource is actually templated and posted to the server. We could reference resources from the composition or resources that aren't even part of the composition. For referenced resources within the composition we could simplify the reference and don't need to put all defining properties like group, version, kind, name and namespace, but rather only the name of the resource in the composition. All the rest can be deferred from the manifest of the referred resource in the composition.

jonnylangefeld avatar Sep 22 '21 17:09 jonnylangefeld

@jonnylangefeld I just created https://github.com/crossplane-contrib/provider-kubernetes/issues/13 for a design proposal to enhance provider kubernetes with a few new features and it looks the one that you are looking for is exactly what I'm proposing.

  • I created a reference implementation at: https://github.com/morningspace/provider-kubernetes/tree/capabilities-shim.
  • A demo project to demonstrate the idea at: https://github.com/morningspace/capabilities-shim.
  • All design details on the features that I'm proposing are documented at: https://github.com/morningspace/capabilities-shim/blob/main/docs/enhanced-provider-k8s.md.

Feel free to make comment or suggestion.

cc: @turkenh @negz

morningspace avatar Oct 19 '21 03:10 morningspace

Maybe a dependsOn array of objects with resource references defined by group, version, kind, name and namespace.

This has been addressed since https://github.com/crossplane-contrib/provider-kubernetes/pull/21 is merged. See examples at: https://github.com/crossplane-contrib/provider-kubernetes/tree/main/examples/object/references

@jonnylangefeld

morningspace avatar Feb 24 '22 00:02 morningspace

I lost alot of time thinking dependsOn would prevent the resource from being composed only to find out crossplane was not waiting. misleading. thanks for this issue.

shanproofpoint avatar Aug 19 '22 19:08 shanproofpoint