jkube icon indicating copy to clipboard operation
jkube copied to clipboard

Allow additional services besides the default

Open manusa opened this issue 2 years ago • 1 comments

Component

JKube Kit

Is your enhancement related to a problem? Please describe

Our current DefaultServiceEnricher will act in three alternate ways:

  • Add services defined in XML configuration
  • Merge service configuration if a service exists
  • Add a new service for the default deployment

The following code snippet is responsible for this: https://github.com/eclipse/jkube/blob/d653e0b6629d4fb15fecd60503e510dca5739523/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultServiceEnricher.java#L129-L146

This doesn't allow the definition of multiple services in case additional deployments or controller types are defined with fragments.

Describe the solution you'd like

The DefaultServiceEnricher#hasServices method should be improved to check if any of the existing services has a matching selector.

This might be complex because at the moment the service selector is provided later on in the ProjectLabelEnricher.

https://github.com/eclipse/jkube/blob/4dfae9e6fa816873547d49651e05070c28e2d00e/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ProjectLabelEnricher.java#L86-L96

  • :bulb: :question: A solution might be to check if the existing service has a selector, in which case we should avoid merging, and adding a default service.

  • :bulb: :question: The merge is also checking for the service name. Maybe we should just rely on that.

Describe alternatives you've considered

No response

Additional context

No response

manusa avatar Jul 23 '22 08:07 manusa

What happens with a service fragment that has no name?

manusa avatar Aug 09 '22 09:08 manusa

What happens with a service fragment that has no name?

Currently, resource fragments are based on this pattern of having <resourceName>-<kind>.<extension> https://github.com/eclipse/jkube/blob/de05bef3d207460965cfd0d895ea4d04d7223114/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/KubernetesHelper.java#L94

We set default name if <resourceName> is not provided in fragment file name: https://github.com/eclipse/jkube/blob/de05bef3d207460965cfd0d895ea4d04d7223114/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/api/util/KubernetesResourceUtil.java#L304-L306

I think relying on name should suffice, If not I can also add a fallback check for LabelSelector

rohanKanojia avatar Oct 20 '22 18:10 rohanKanojia