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

Multi Cluster Support #1308

Open
bs-matil opened this issue Jun 30, 2022 · 10 comments · Fixed by #2499
Open

Multi Cluster Support #1308

bs-matil opened this issue Jun 30, 2022 · 10 comments · Fixed by #2499
Labels

Comments

@bs-matil
Copy link

As discussed in #1307 it would be nice to have cluster a context setting for each controller.

Why?
Currently a operator can only a act on a single context. Traditionally that's fine as an operator often orchestrates only resources in the very cluster its deployed it self. In this scenario the operator gets its identity natively from the kubernetes context and is statically configured for its own cluster.
In contrast to that we have a use case where we manage multiple clusters with on operator which is deployed to a meta/central cluster. The operator still manages resources within this meta cluster but to instantiate the desired application it will also manage child/runtime clusters.

Example:

The control cluster manages a CRD which has been instantiated twice. The operator picks them up and deploys resources to fulfil the desired resource. To do that the operator has to deploy the application into multiple clusters which are e.g. physically separated and therefore can't have a single identity or are separated due to availability needs or to test new versions of kuberentes etc. Therefore a full replication of the resources is created in each cluster and the operator watches all of them.

Control Cluster
┌──────────────────────────────┐  Cluster A
│                              │ ┌──────────────────────────────────────────┐
│    Namespace-crds            │ │  Namespace-A            Namespace-B      │
│    ┌──────────────┐      ┌───┼─┤►┌─────────────┐       ┌─────────────┐    │
│    │              │      │   │ │ │             │       │             │    │
│    │ CRD-A        │      │   │ │ │ Deployment  │       │  Deployment │    │
│    │ CRD-B        │      │   │ │ │             │       │             │    │
│    │              │      │   │ │ └─────────────┘       └─────────────┘    │
│    └─────▲────────┘      │   │ │                                          │
│          │               │   │ └──────────────────────────────────────────┘
│          │ Reconcile     │   │
│          │               │   │  Cluster B
│     ┌────┴────────┬──────┘   │  ┌──────────────────────────────────────────┐
│     │             │          │  │  Namespace-A            Namespace-B      │
│     │  Operator   ├──────────┼──┤►┌─────────────┐       ┌─────────────┐    │
│     │             │  Create/ │  │ │             │       │             │    │
│     └─────────────┘  Reconcile  │ │ Deployment  │       │  Deployment │    │
│                              │  │ │             │       │             │    │
│                              │  │ └─────────────┘       └─────────────┘    │
│                              │  │                                          │
└──────────────────────────────┘  └──────────────────────────────────────────┘

Goals:

  • add a context setting for the controller annotation so context can be in addition to the namespace for each reconciler individually
  • add startup probe to ensure all desired context are available
@jmrodri
Copy link
Member

jmrodri commented Jun 30, 2022

Controller runtime had an issue about multi cluster support: kubernetes-sigs/controller-runtime#745 (comment) and a POC kubernetes-sigs/controller-runtime#950

@csviri csviri added this to the 3.3 milestone Jul 13, 2022
@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 12, 2022
@csviri csviri removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 12, 2022
@csviri csviri modified the milestones: 4.1, 4.2 Sep 28, 2022
@csviri csviri added the feature label Oct 3, 2022
@operator-framework operator-framework deleted a comment from github-actions bot Oct 28, 2022
@juangon
Copy link

juangon commented Oct 28, 2022

Wow, this would be a great feature. In my case we are using operators to provision applications and having the chance to select which cluster (maybe in other clouds) can be great

@csviri
Copy link
Collaborator

csviri commented Oct 31, 2022

So thinking about this issue more, the real benefits would be:

  1. Have a out of the box access/experinece to other clusters and able to register informers that will trigger the reconciliation regarding a custom resource on a different cluster.
  2. Manage resources on different clusters in a sense that reconciler is able to make decision based on a global state (taking in mind resources on multiple clusters)

But also we have to be very careful about this, since this has a huge impact on overall architecture and the use case might target only a small subset of users. (Just think how would you model this in terms of a dependent resource? )

So I would recommend to create a prototype to see more clearly the implications, and make decision if we want to do this or not at the end.

@csviri csviri modified the milestones: 4.2, 4.3 Nov 8, 2022
@csviri csviri changed the title Switch context for specific reconciler (add multi cluster support) Multi Cluster Support Nov 11, 2022
@csviri
Copy link
Collaborator

csviri commented Nov 11, 2022

This is a very interesting argument, why actually this makes sense in general to have:
https://youtu.be/1p00SMLletY?t=1249

Although this not necessarily about the multiple clusters in one instance, but nice example how to manage resources from an other cluster and why it makes sense.

@csviri csviri modified the milestones: 4.3, 5.0 Jan 27, 2023
@csviri
Copy link
Collaborator

csviri commented Mar 14, 2023

see also: #1817

@csviri csviri removed this from the 5.0 milestone Jun 27, 2023
@katheris
Copy link
Contributor

Hey, is there any update on this feature? I work on the Strimzi Access Operator which is responsible for delivering connection details for a Kafka cluster to Kafka applications. We are looking at a usecase where you have one Kubernetes cluster hosting your Kafka cluster, and a different one hosting your Kafka applications. So the operator would only watch for CRs in a single Kubernetes cluster, but could query on Kubernetes clusters as part of the reconciliation loop.

Strimzi issue for reference.

@csviri
Copy link
Collaborator

csviri commented Aug 13, 2024

Hi @katheris
Having a generic multi cluster support is quite complex change. But having Informers watching different clusters might be something doable (your use case). Will create a separate issue with such scope.

see issue with limited scope here: #2493

@csviri
Copy link
Collaborator

csviri commented Aug 15, 2024

@katheris created the PR: #2499
that includes a sample, tbh I think this covers the original request within this issue.

@csviri
Copy link
Collaborator

csviri commented Aug 15, 2024

Just a side not having a controller managing primary resources (not just secondary resources as in the PR above) from multiple clusters is more complex to implement, but definitely doable. Pls let us know if that is needed.

@katheris
Copy link
Contributor

For our usecase we only need to manage secondary resources in a different Kubernetes cluster, the controller will be deployed in the same cluster as both the CR it is the controller for, and any primary resources it creates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants