define shared component in different appconfig
Now appconfig can easily define independent component, but if I have two application use same component, this could be hard to define in current spec.
For example:
Project Group A develop and deploy an App called AppA, with two components, one is mysql, the other one is a web service. The yaml may look like below:
apiVersion: core.oam.dev/v1alpha1
kind: ApplicationConfiguration
metadata:
name: AppA
spec:
components:
- componentName: web-app
instanceName: web-app-instance
- componentName: mysql
instanceName: mysql-instance
Project Group A deploy AppA and insert lots of data into mysql.
After few days, another Project Group B set up, they hope to create an AppB use the same mysql of AppA, maybe use the data to do something, so they must share same mysql instance.
OAM spec didn't define such case.
There are two possible solutions for this case:
Solution 1: Use the same instanceName means share component
apiVersion: core.oam.dev/v1alpha1
kind: ApplicationConfiguration
metadata:
name: AppB
spec:
components:
- componentName: web-app-b
instanceName: web-app-b-instance
- componentName: mysql
instanceName: mysql-instance
The benifit of this solution is that the spec don't need to change, while we must declare the instanceName of component must be unique globally.
Solution 2: Add instanceRef field represent sharing with another AppConfig
apiVersion: core.oam.dev/v1alpha1
kind: ApplicationConfiguration
metadata:
name: AppB
spec:
components:
- componentName: web-app-b
instanceName: web-app-b-instance
- componentName: mysql
instanceName: mysql-instance
instanceRef: AppA
This don't require instanceName is unique, and we add a compatible field instanceRef into AppConfig spec.
A related issue would be "global trait".
I would vote for instanceRef, as it is very similar to what CloudFormation would do for instance.