-
Notifications
You must be signed in to change notification settings - Fork 80
Use label to replace workloadRef #4
Comments
(Optional) I am also thinking we can use labels to track the bi-directional links between dev facing objects (Component/Workload) with ops facing objects (Trait/Scope). |
I think it's more common to use references to track one-to-one relationships than labels, which are typically used to track one-to-many relationships. It seems like the rationale here is more about not imposing requirements on the schema of a trait CR than because labels are inherently more appropriate for this case than references. Could you illustrate some cases in which we might want to use an existing, OAM-unaware Kubernetes CR as an OAM trait? |
@negz Yes, happy to illustrate. In the wild, many Operators are "Workload + Trait" style by natural. For instance, backup capability of etcd-operator: Workload: apiVersion: "etcd.database.coreos.com/v1beta2"
kind: "EtcdCluster"
metadata:
name: "example-etcd-cluster"
## Adding this annotation make this cluster managed by clusterwide operators
## namespaced operators ignore it
# annotations:
# etcd.database.coreos.com/scope: clusterwide
spec:
size: 3
version: "3.2.13" Trait: apiVersion: "etcd.database.coreos.com/v1beta2"
kind: "EtcdBackup"
metadata:
name: example-etcd-cluster-backup
spec:
etcdEndpoints: [<etcd-cluster-endpoints>]
storageType: S3
s3:
# The format of "path" must be: "<s3-bucket-name>/<path-to-backup-file>"
# e.g: "mybucket/etcd.backup"
path: <full-s3-path>
awsSecret: <aws-secret> Similar patterns also exist in serverless solutions such as knative configuration + route. Also, with the community begin to focus on application centric, many existing capabilities are re-designed as higher level abstractions (decoupled from underlying workload) so they can be used directly as OAM trait, for example Ingress v2 API. These patterns may not be the majority for now but I think it's a trend that we can consider support at day 0 by loose the enforcement on CRD. |
Btw, since we still need to add GVK + name in labels, it's seems no implication for "one-to-many" relationship. |
We can't enforce existing CRD/Operators to add workloadRef in their spec, however some of them could be very good OAM traits. Using label could add them into OAM system without any change. What's more, I suggest to use some unique id to be label, for example: |
@resouer @wonderflow I like the idea of being able to bring arbitrary CRD types to the OAM model and allow them to serve as traits. Labels seem like a nice way to do this as they will be available to set on any type. However, I want to make sure we consider all alternatives here. The first that would come to mind would be implementing a separate type for binding traits to workloads (similar to trait-injector). Do you have thoughts on the pros and cons of these two models? |
Here is a list of options:
If the only requirement is not to add any field into existing Trait CR, both 2 and 3 should work. |
close this as we have decided to use field |
Since a Trait CR 1:1 maps to Workload CR, maybe we can consider using label/annotation to replace
trait.workloadRef
?e.g.
The benefit is as Trait could also be brought by user, we don't want to require user modify CRD before using Crossplane.
(Optional) The link can also be
Component
if we agree onComponent
won't be shared in oam-dev/spec#350./cc @negz @ryanzhang-oss
The text was updated successfully, but these errors were encountered: