oam-kubernetes-runtime icon indicating copy to clipboard operation
oam-kubernetes-runtime copied to clipboard

[Question] Can an ApplicationConfiguration deploy Components to different namespaces?

Open mgianatagh opened this issue 5 years ago • 2 comments

My use case is that I would like to create a single ApplicationConfiguration that would deploy Components into designated namespaces. As opposed to creating an ApplicationConfiguration for each namespace. Is this a use case that is or will be supported?

I tried to accomplish this using a parameter to set the metadata.namespace value for the component.

My test component file was as follows. I created it in the default namespace.

apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
  name: robert-helidon
spec:
  workload:
    apiVersion: core.oam.dev/v1alpha2
    kind: ContainerizedWorkload
    metadata:
      name: robert-helidon
      labels:
        app: robert-helidon
    spec:
      containers:
        - name: robert-helidon-stock-application
          image: "foo"
  parameters:
    - name: instance-namespace
      fieldPaths:
        - metadata.namespace

My test ApplicationConfiguration file was as follows. I created it in the default namespace and pre-created the namespace robert.

apiVersion: core.oam.dev/v1alpha2
kind: ApplicationConfiguration
metadata:
  name: robert
  annotations:
    version: v1.0.0
    description: "Robert"
spec:
  components:
    - componentName: robert-helidon
      parameterValues:
        - name: instance-namespace
          value: robert

The result was that application was deployed to the default namespace instead of robert

mgianatagh avatar Oct 08 '20 13:10 mgianatagh

Hi @mgianatagh , cross-namespace operation is complex and unpredictable in Kubernetes and I am afraid it will create heavy burden on the trait implementation side.

Not sure if you envision this as a feature for OAM runtime? Or you just hope to save time to copy-paste AppConfig in multiple namespaces? The latter scenario could be partially fixed by yaml tools like kustomize etc.

resouer avatar Oct 08 '20 18:10 resouer

Thank you for your response.

I was envisioning this as a feature. For the scenario I was using as a test case, the complete application needs to be deployed to three separate namespaces. For me it would have been preferable to see the entire layout of the application in a single ApplicationConfiguration file.

mgianatagh avatar Oct 09 '20 11:10 mgianatagh