spec icon indicating copy to clipboard operation
spec copied to clipboard

define shared component in different appconfig

Open wonderflow opened this issue 6 years ago • 2 comments

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.

wonderflow avatar Nov 01 '19 08:11 wonderflow

A related issue would be "global trait".

resouer avatar Nov 01 '19 20:11 resouer

I would vote for instanceRef, as it is very similar to what CloudFormation would do for instance.

AdrienFromToulouse avatar Nov 06 '19 20:11 AdrienFromToulouse