-
Notifications
You must be signed in to change notification settings - Fork 17
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
Feature Request: Support Multiple Strategies for ClusterSet Failover #449
Comments
Thank you @kahirokunn Good idea. I see one problem though. If Sveltos cannot access the unhealthy cluster anymore, then it cannot remove add-ons from there. Which can, with this approach, block Sveltos from moving forward. How do you suggest we cover this scenario in this proposal? Thank you! |
For reference, may I ask first about the current Failover behavior? (Actually, I don't think I can find it described anywhere. Thx 🙏 |
@gianlucam76 Thank you! |
@kahirokunn when you create a ClusterSet it selects matching clusters. Usually you create a ClusterSet to match two clusters only. And in the ClusterSet you specify how many clusters must be active. Usually you say only one cluster. So ClusterSet selects cluster A and B for instance. And ClusterSet out of those two clusters, decides that Cluster A is active and Cluster B is backup. As long as Cluster A is healthy (apiserver is reachable) all add-ons and applications are deployed there. At this point all add-ons and applications are deployed there. Nothing happens to Cluster A as apiserver is not reachable. So Sveltos does not even try to remove add-ons and applications. |
@gianlucam76 I have one more question. Could you please explain in more detail about the Unhealthy status mentioned in the following document? Thx again 🙏 |
Thanks @kahirokunn Sveltoscluster controller periodically (every minute) queries apiserver of every registered cluster. When the query fails for a number (configurable) of consecutive times, Sveltos says this cluster is unhealthy because apiserver is down. And while no other resources in the managed cluster are looked at, extending this to check also resources in the cluster (assuming of course apiserver is reachable) would be very easy to achieve |
Thank you! Feature Request: Implementation of Flexible Failover Control Using Prometheus MetricsOverviewCurrently, there is a risk that all ClusterProfiles may automatically failover even when there are only temporary intermittent communications issues between the management cluster (mgmt cluster) and the managed cluster's apiserver. In particular, network failures or apiserver downtime don't necessarily mean a loss of application-level availability. Considering such cases, we propose incorporating metrics-based mechanisms like Prometheus rather than relying solely on apiserver accessibility for failover triggers, enabling more flexible and appropriate failover control. Background and Issues
Additional Proposal: Prometheus Metrics-Based Failover Decision MakingBased on these issues, we propose adding a metrics-based mechanism using Prometheus as follows:
Implementation and Operational Benefits
SummaryImplementing failover based solely on apiserver accessibility could lead to unnecessary failovers during temporary network failures or authentication infrastructure issues, potentially creating significant risks. Therefore, we propose enabling failover decisions based on application operational status using Prometheus metrics. We believe more flexible and safer failover control can be achieved by incorporating native implementation into sveltos while referencing metrics utilization mechanisms from existing OSS like Flagger, Keptn, and Keda. |
Thank you @kahirokunn Let me see if I got it. Metrics are pulled from managed cluster to management cluster or collected and exposed via reachable IP (which is outside the scope of Sveltos and this request). Sveltos is also instructed to get and check those metrics (scope of this request). And decide whether a failover is needed using also those Is that correct understanding of this proposal? |
Yes, that's right. |
Thank you for sharing this! Through our discussion, I was able to better organize my thoughts. Upon further review, I've discovered some interesting points about metrics implementation that I'd like to share. It appears that representing metrics as custom resources is already possible, and there's an existing operator for this purpose in the Keptn Lifecycle Toolkit: https://github.com/keptn/lifecycle-toolkit/tree/main/metrics-operator Building on this, I believe we could enhance the failover functionality in ClusterSet/Set by leveraging the status of KeptnMetric custom resources as triggers. This approach could be particularly powerful because:
I've created a proof of concept showing how ClusterSet could perform failover based on metrics. Here's the example: apiVersion: lib.projectsveltos.io/v1beta1
kind: ClusterSet
metadata:
name: prod
spec:
clusterSelector:
matchLabels:
env: prod
maxReplicas: 1
templateResourceRefs:
- resource:
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
name: "{{ .Cluster.metadata.name }}-http-success-rate-metric"
namespace: "{{ .Cluster.metadata.namespace }}"
identifier: httpSuccessRate
- resource:
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
name: "{{ .Cluster.metadata.name }}-kubelet-error-rate-metric"
namespace: "{{ .Cluster.metadata.namespace }}"
identifier: kubeletErrorRate
- resource:
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
name: "{{ .Cluster.metadata.name }}-kubeApiserver-error-rate-metric"
namespace: "{{ .Cluster.metadata.namespace }}"
identifier: kubeApiserverErrorRate
validateHealths:
- script: |
function evaluate()
local hs = {
healthy = true,
message = "cluster is healthy"
}
local httpSuccessRate = tonumber(ctx.httpSuccessRate.status.value) or 0
local kubeletErrorRate = tonumber(ctx.kubeletErrorRate.status.value) or 0
local kubeApiserverErrorRate = tonumber(ctx.kubeApiserverErrorRate.status.value) or 0
if httpSuccessRate <= 0.1 and (kubeletErrorRate + kubeApiserverErrorRate) <= 1.0 then
hs.healthy = false
hs.message = "too many errors"
end
return hs
end Thank you 🙏 |
Thank you. This is cool and very inline with rest of Sveltos. I think it makes sense to deliver this. Let's file an enhancement request for addon controller |
Thank you! |
Background
There is a request to support multiple strategies regarding the timing and method of removing (uninstalling) ClusterProfiles from unhealthy clusters during ClusterSet failover operations.
Specifically, three strategies are being considered:
CreateBeforeDestroy
Install the ClusterProfile on the new cluster after completing the uninstallation from the unhealthy cluster.
DestroyBeforeCreate
Uninstall the ClusterProfile from the unhealthy cluster after completing the installation on the new cluster.
CreateOnly
After installing the ClusterProfile on the new cluster, leave it as-is on the unhealthy cluster without uninstalling.
Currently, these strategies are not explicitly defined in the documentation or specifications, or there appears to be no control method provided.
Request Details
We would like to support multiple failover strategies, similar to StatefulSet and Deployment, allowing users to select them as needed.
The main request is to support these three control methods:
Ideally, being able to apply different strategies ("CreateBeforeDestroy", "DestroyBeforeCreate", "CreateOnly") per ClusterProfile (for example, using labelSelector) for unhealthy clusters would allow flexible responses to various use cases.
Use Cases
Expected Benefits
Proposal
Conclusion
This is a request to enable selection from multiple strategies for ClusterProfile uninstallation procedures and timing during cluster failover.
In particular, we hope for a design that can accommodate various use cases, such as strategies that allow migration to new environments without uninstallation.
We appreciate your consideration of this request.
The text was updated successfully, but these errors were encountered: