-
Notifications
You must be signed in to change notification settings - Fork 80
[Feature]OAM Runtime should allow different workloadDefinitions to point to the same workload Schema #195
Comments
The For example: apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
name: frontend
spec:
workload:
type: Server
spec:
image: nginx
port: 80 For backward compatible implementation, the go types in my mind will be: type ComponentSpec struct {
Workload WorkloadTemplate
Parameters []ComponentParameter
}
type WorkloadTemplate struct {
Type string
Spec runtime.RawExtension
runtime.RawExtension // for GVK object, this field is exclusive to Type
} |
This also makes it right that |
I am not sure if this is compatible with the current structure. as the workload itself is already declared as a RawExtention. It might be doable but pretty tricky and not sure what does that buy. The below structure is fully backward compatible and easy to implenent. type ComponentSpec struct {
Type String
Workload runtime.RawExtension
Parameters []ComponentParameter
} |
After further discussion, we have decided to take the format below but keep the API structure. So we will just parse the rawExtension as is and if there is a "Type" top key then we will use that to locate the workloadDefinition and add the GVK back to the CR. In this case, the CR should not have GVK and metadata.
|
@ryanzhang-oss Can you provide some example scenarios for this problem? |
When WorkloadDefinition doesn't follow the pattern <puraral-kind>.<resource-group> or there are different workloadDefinitions pointing to the same workload Schema, it will hit the issue of could not finding workloaddefinition. Fix issue crossplane#207, feature crossplane#195. Signed-off-by: zzxwill <[email protected]>
When there is spec.type in Workload, an annotation will set for the workload which can help find the WorkloadDefinition. Fix issue crossplane#207, related to feature crossplane#195. Co-authored-by: Sun Jianbo <[email protected]> Signed-off-by: zzxwill <[email protected]>
When there is spec.type in Workload, an annotation will set for the workload which can help find the WorkloadDefinition. Fix issue crossplane#207, related to feature crossplane#195. Co-authored-by: Sun Jianbo <[email protected]> Signed-off-by: zzxwill <[email protected]>
When there is spec.type in Workload, an annotation will set for the workload which can help find the WorkloadDefinition. Fix issue crossplane#207, related to feature crossplane#195. Co-authored-by: Sun Jianbo <[email protected]> Signed-off-by: zzxwill <[email protected]>
When there is spec.type in Workload, an annotation will set for the workload which can help find the WorkloadDefinition. Fix issue crossplane#207, related to feature crossplane#195. Co-authored-by: Sun Jianbo <[email protected]> Signed-off-by: zzxwill <[email protected]>
* Fix `could not find WorkloadDefinition` issue When there is spec.type in Workload, an annotation will set for the workload which can help find the WorkloadDefinition. Fix issue #207, related to feature #195. Co-authored-by: Sun Jianbo <[email protected]> Signed-off-by: zzxwill <[email protected]> * Address comments and add unit-test Signed-off-by: zzxwill <[email protected]> * Fix goimports issue Signed-off-by: zzxwill <[email protected]> * Change function name and add unit-test Signed-off-by: zzxwill <[email protected]> * Removed maker annotation `definition.oam.dev/name` Signed-off-by: zzxwill [email protected] Signed-off-by: zzxwill <[email protected]> Co-authored-by: Sun Jianbo <[email protected]>
Is your feature request related to a problem? Please describe.
Currently, we only allow one workloadDefinition to point to the one workload Schema by tying its name to the schema name of the workload. This leads to the problem of not able to express different types of workloads with the same schema.
Describe the solution you'd like
We will decouple the name of the workloadDefintion from the name of workload schema. In order to achieve this, we will propose to add an optional "type" field in the Component to point to the name of the "workloadDefinition" it is referring to. This is fully backward compatible with the current schema. Here is an example.
Describe alternatives you've considered
Add a workloadDefinition controller that watches all the resources of type "CRD" and add an owner reference to itself when it detects a new resource of type "CRD" is created. This is a pretty heavy process and can lead to user confusion.
The text was updated successfully, but these errors were encountered: