Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions docs/designs/hub-controller-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Multi-Cluster Hub Controller Design

## Problem

* There is no simple way for the promotion token from a demoted cluster to
transfer to the newly promoted cluster
* There needs to be a central location where Azure DNS can be managed
* We need some way to manage the failover of many DocumentDB instances at once

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also want a central controller to manage failovers - planned and unplanned. Additionally we need to control backups centrally to move backup schedules to all sites so we can perform a site swap and still have backups.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this controller needs to be handled in our update design -- please research how it cna play a role during update aka it should probably corrdinate multi-region/cloud updates of oeprators and individual DocumentDB clusters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add info about a health check. For Updates I think we should use fleet itself to coordinate multi-cloud updates, but I'll add that to the design here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the controller can probably help to manage operator updates, I think it would be better to use fleet's staged update process instead of creating our own, and then let the operators themselves manage the updates of the individual documentdb clusters

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume we have only one replica in each region - during update we will need to fail over to another region and then update that region. We can of course defer this case to future work and assume the primary region during update is HA enabled and the local operator will handle the feailovers automatically

## Implementation

This will be a separate k8s operator running in the KubeFleet hub,
It will try to remain as minimal as possible.

### Promotion token management

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for promotion it should determine which remote clister has the highest LSN and pcik that one to minimze data transfer time and downtime. Potentially user cna overwrite and focrce a specific region but that's needs to be not the default behavior.

The Controller will be able to query the Kube API on the member clusters to
get the promotion token from the Cluster CRD. Then it will create a configMap
and CRP to send that token to the new primary cluster. It will use the
documentdb crd to determine which member is primary.

It will clean up the token and crp when the promotion is complete.
It can determine this through the Cluster CRD status.

### DNS Management

If requested in the documentdb object, the controller should also
provision and manage an Azure DNS zone for the documentdb cluster.
This will create an SRV DNS entry that points to the primary for
seamless client-side failover, as well as individual DNS entries
for each cluster.

This will need the following information

* Azure Resource group
* Azure Subscription
* DNS Zone name (optional, could be generated on the fly)
* Azure credentials
* Parent DNS Zone (optional)
* Parent DNS Zone RG and Subscription

### Regional Failover

The user should be able to initiate a regional failover, wherein all clusters in
a region change their primary. The controller should know the LSNs on each
instance, and pick the highest for each cluster to become the new primary. To
initiate this failover, the user should create a CRD that marks a particular
member cluster as not primary-ready. The controller will watch this resource,
and use that information to update each DocumentDB instance. The crp will
automatically push those changes, and the Operators will perform the actual
promotions and demotions

## Other possible additions

### Streamlined Operator and Cluster deployment

This new controller could theoretically handle the installation and
distribution of the cert manager and the operator to save the user from
having to deploy a large and cumbersome CRP. It could also monitor
the DocumentDB CRD and automatically create a CRP for that matching
the provided clusterReplication field.

### Pluggable DNS management

The DNS management could be abstracted to allow for other cloud's
DNS management systems. The current implementation will create an
API that will extensible.

## Updates

Updates of the operators will be coordinated through KubeFleet's
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do operator updates through the fleet functionality... on the fence if we need to put that in the opertaor so a user can run kubectl documentdb update operators?

In any case we need to control the update of individual multi-region/cloud doucmentdb clusteres through the controller - so users can d that with just one command and it will roll out accordingly (optionally plau into fleet's deployment mechanism)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that documentdb updates at that precise a level should probably be handled at the operator level, not by a multi-cloud controller.

ClusterStagedUpdateStrategy. This will allow the operators to safely
update with optional rollbacks. The controller itself should be able to
be updated independently of the operators. Steps will be taken to ensure
backwards compatibility through the use of things like feature flags and
deprecating but maintaining old APIs.

## Security considerations

This operator will have no more access than the fleet manager already
does, and the member cluster operator endpoints will be limited to the
least amount of information provided possible and only grant access
to the fleet controller.

## Alternatives

Currently, we perform this promotion token transfer using a nginx pod
and a multi-cluster service when using KubeFleet. The DNS zone creation
and management is handled by the creation and failover scripts.

## References

* [KubeFleet Staged Update](https://kubefleet.dev/docs/how-tos/staged-update/)
Loading