Open resouer opened 4 years ago
/cc @vturecek @hongchaodeng @ryanzhang-oss @artursouza @wonderflow for review.
We should not assume Definition always has same name with defitionRef
.
We should probably make appliesTo more intelligent:
appliestTo:
- group: apps
kinds: Deployment, StatefulSet
labelSelector:
workload.oam.dev/podSpecable=true
- ...
Then in each WorkloadDefinition we could add the hints into their labels:
kind: WorkloadDefinition
metadata:
labels:
workload.oam.dev/replicable: true # can be scale
workload.oam.dev/podspecable: true # can be addressed by k8s podSpec
LGTM on a high level, here are some minor details
workloadDefinition
refer to the same workload schema. We can have two workloads
that behave differently while sharing the same schema. Thus, we need to decouple the name of the workloadDefinition
from the name of the schema (CRD) it refers to.+1 to use label/selector instead of introducing new field.
LGTM with using label
It seems important to be able to filter on the workload's definitionRef (or something equivalent). This aligns with the initial comment from @resouer above. However the mixing of actual labels with API resources as suggested there seem problematic. On the other hand, being more explicit and using labelSelector
seems to eliminate the possibility of limiting trait applicability by API resource. Unless perhaps there was some automatically applied workloadDefinition label (e.g. workload.oam.dev/resource=cloneset.apps.alibaba-inc.com). Another option would be for the TraitDefinition to have both a labelSelector and some for of resource selector or matchExpressions construct.
@kminder Hi Kevin, just to confirm, you are suggesting using structured fields, or a specific object (e.g. WorkloadType) instead of labels to carry these characteristic (i.e. replicable) data, right? This was the original plan, but we didn't see much value except extra burden for one more object. Would you like to elaborate your insights a bit?
Consider adding operational hints (workload characteristic) on workload definition:
The
appliesTo
will work like this:Also related: https://github.com/crossplane/oam-kubernetes-runtime/issues/174