Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: option to limit CRs the operator should handle #1943

Closed
lburgazzoli opened this issue Jan 25, 2021 · 9 comments · Fixed by #2683
Closed

operator: option to limit CRs the operator should handle #1943

lburgazzoli opened this issue Jan 25, 2021 · 9 comments · Fixed by #2683
Assignees
Labels
area/core Core features of the integration platform area/installation Installation and Topology area/managed-service Camel K as a Managed Service
Milestone

Comments

@lburgazzoli
Copy link
Contributor

lburgazzoli commented Jan 25, 2021

We should be able to restrict what CRs a camel-k operator should handle, as example, we can add a label like camel.apache.org/operator.id to each CR:

apiVersion: camel.apache.org/foo
kind: bar
metadata:
  labels: 
    camel.apache.org/operator.id: "operator-1"

The operator.id should also be used to acquire the operator lock.

Note:

  • We'd need to amend the kamel commands to eventually take into account such label
  • We'd need to introduce a new command to move CR between operators
@astefanutti astefanutti changed the title operator: option lo limiti CRs the operator should handle operator: option to limit CRs the operator should handle Jan 25, 2021
@nicolaferraro nicolaferraro modified the milestones: 2.0.0, 1.4.0 Jan 25, 2021
@astefanutti
Copy link
Member

Ideally, these labels should be taken into account by the controller-runtime informer that watches for Integration resources, to filter sever-side, so that the corresponding operator does not filter client-side and cache the out-of-scope Integrations, so that the solution scales nicely.

@astefanutti
Copy link
Member

astefanutti commented Jan 25, 2021

Ideally, these labels should be taken into account by the controller-runtime informer that watches for Integration resources, to filter sever-side, so that the corresponding operator does not filter client-side and cache the out-of-scope Integrations, so that the solution scales nicely.

It seems like server-side filtering is not yet possible with controller-runtime: kubernetes-sigs/controller-runtime#244.

We can go for a client-side predicate in the meantime.

@astefanutti astefanutti added the area/core Core features of the integration platform label Jan 25, 2021
@nicolaferraro nicolaferraro modified the milestones: 1.4.0, 1.5.0 Mar 16, 2021
@lburgazzoli
Copy link
Contributor Author

One of the use case where is feature can be useful is to implement "rolling upgrade" of the camel-k operator where you have multiple running version of the camel-k operator and you want to move integrations from one operator to the another by steps.

The simplest approach is to change the label i.e. from camel.apache.org/operator.id: "operator-1" to camel.apache.org/operator.id: "operator-2" however this may not be enough as "operator-1" may be performing some work and changing the label may leave the integration in a inconsistent state so we may need to introduce a camel-k level finalizer concept to let the operator currently owning a resource to gracefully release a resource and moving it to the target operator.

@astefanutti @nicolaferraro what do you think ?

@astefanutti
Copy link
Member

astefanutti commented Apr 19, 2021

Right. As we are introducing a mechanism where multiple operators can concurrently manage the same resources, a locking mechanism is necessary. More generally to the rolling upgrade use-case, that mechanism would make sure that only a single operator manages the same resource at a single point in time. That would prevent issues where the label selectors for multiple operators intersect.

Now on how to implement that locking mechanism, I think we could reuse the approach used for locking by multiple replicas of the same operator, that is with a Lease resource, but owned by the Integration. The Lease resource seems the preferred mechanism (by client-go and controller-runtime), and handle use cases such as renewing and deadlining nicely. It would also be an extension of the locking implementation already in place for managing HA of the operator replicas.

@heiko-braun
Copy link

Is the camel.apache.org/operator.id used to describe an instance of an operator?

@heiko-braun
Copy link

heiko-braun commented Apr 19, 2021

+1 on the lease resource for managing locks.

@astefanutti astefanutti added the area/installation Installation and Topology label May 3, 2021
@astefanutti astefanutti self-assigned this May 3, 2021
@lburgazzoli
Copy link
Contributor Author

@astefanutti we should also take into account the IntegrationPlatform CR i.e. if multiple operators are installed in the same namespace, it should be possible to have multiple instances of the IntegrationPlatform labeled according so only the relevant operator would use it (note: we may think about naming the maven settings config map after the selector label) .

@astefanutti
Copy link
Member

@astefanutti we should also take into account the IntegrationPlatform CR i.e. if multiple operators are installed in the same namespace, it should be possible to have multiple instances of the IntegrationPlatform labeled according so only the relevant operator would use it (note: we may think about naming the maven settings config map after the selector label) .

Right, scoping IntegrationPlatform should be supported in addition to scoping Integration. actually, I think scoping must be implemented for any kind of resources being watched / managed by the operator, like IntegrationKit, Build, ... Even for environments that do not leverage the builder, I think it makes sense to implement a generic scoping mechanism.

@astefanutti
Copy link
Member

Selectors support has been added to k8s informers into the latest version of controller-runtime: kubernetes-sigs/controller-runtime#1435.

@nicolaferraro nicolaferraro modified the milestones: 1.5.0, 1.6.0 Jul 5, 2021
@nicolaferraro nicolaferraro added the area/managed-service Camel K as a Managed Service label Sep 6, 2021
@nicolaferraro nicolaferraro modified the milestones: 1.6.0, 1.7.0 Sep 7, 2021
@nicolaferraro nicolaferraro self-assigned this Oct 7, 2021
@astefanutti astefanutti removed their assignment Oct 7, 2021
nicolaferraro added a commit to nicolaferraro/camel-k that referenced this issue Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Core features of the integration platform area/installation Installation and Topology area/managed-service Camel K as a Managed Service
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants