Merge pull request #3399 from Poor12/binding-api-change

Binding API modification adaptation to implement application failover
This commit is contained in:
karmada-bot 2023-04-19 11:26:12 +08:00 committed by GitHub
commit b9ba007913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 172 additions and 1 deletions

View File

@ -16756,6 +16756,10 @@
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.TargetCluster"
}
},
"failover": {
"description": "Failover indicates how Karmada migrates applications in case of failures. It inherits directly from the associated PropagationPolicy(or ClusterPropagationPolicy).",
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.FailoverBehavior"
},
"gracefulEvictionTasks": {
"description": "GracefulEvictionTasks holds the eviction tasks that are expected to perform the eviction in a graceful way. The intended workflow is: 1. Once the controller(such as 'taint-manager') decided to evict the resource that\n is referenced by current ResourceBinding or ClusterResourceBinding from a target\n cluster, it removes(or scale down the replicas) the target from Clusters(.spec.Clusters)\n and builds a graceful eviction task.\n2. The scheduler may perform a re-scheduler and probably select a substitute cluster\n to take over the evicting workload(resource).\n3. The graceful eviction controller takes care of the graceful eviction tasks and\n performs the final removal after the workload(resource) is available on the substitute\n cluster or exceed the grace termination period(defaults to 10 minutes).",
"type": "array",

View File

@ -264,6 +264,81 @@ spec:
- name
type: object
type: array
failover:
description: Failover indicates how Karmada migrates applications
in case of failures. It inherits directly from the associated PropagationPolicy(or
ClusterPropagationPolicy).
properties:
application:
description: Application indicates failover behaviors in case
of application failure. If this value is nil, failover is disabled.
If set, the PropagateDeps should be true so that the dependencies
could be migrated along with the application.
properties:
blockPredecessorSeconds:
default: 600
description: BlockPredecessorSeconds represents the period
of time the cluster from which the application was migrated
from can be schedulable again. During the period of BlockPredecessorSeconds,
clusters are forcibly filtered out by the scheduler. If
not specified or the value is zero, the evicted cluster
is schedulable to the application when rescheduling. Defaults
to 600s.
format: int32
type: integer
decisionConditions:
description: 'DecisionConditions indicates the decision conditions
of performing the failover process. Only when all conditions
are met can the failover process be performed. Currently,
DecisionConditions includes several conditions: - TolerationSeconds
(optional) - HealthyState (mandatory)'
properties:
tolerationSeconds:
default: 300
description: TolerationSeconds represents the period of
time Karmada should wait after reaching the desired
state before performing failover process. If not specified,
Karmada will immediately perform failover process. Defaults
to 300s.
format: int32
type: integer
type: object
preConditions:
description: 'PreConditions indicates the preconditions of
the failover process. If specified, only when all conditions
are met can the failover process be started. Currently,
PreConditions includes several conditions: - DelaySeconds
(optional) - HealthyState (optional)'
properties:
delaySeconds:
description: DelaySeconds refers to a period of time after
the control plane collects the status of the application
for the first time. If specified, the failover process
will be started after DelaySeconds is reached. It can
be used simultaneously with HealthyState and does not
affect each other.
format: int32
type: integer
healthyState:
description: HealthyState refers to the healthy status
reported by the Karmada resource interpreter. Valid
option is "Healthy". If specified, the failover process
will be started when the application reaches the healthy
state. It can be used simultaneously with DelaySeconds
and does not affect each other.
type: string
type: object
purgeMode:
default: Graciously
description: PurgeMode represents how to deal with the legacy
applications on the cluster from which the application is
migrated. Valid options are "Immediately", "Graciously"
and "Never". Defaults to "Graciously".
type: string
required:
- decisionConditions
type: object
type: object
gracefulEvictionTasks:
description: 'GracefulEvictionTasks holds the eviction tasks that
are expected to perform the eviction in a graceful way. The intended

View File

@ -264,6 +264,81 @@ spec:
- name
type: object
type: array
failover:
description: Failover indicates how Karmada migrates applications
in case of failures. It inherits directly from the associated PropagationPolicy(or
ClusterPropagationPolicy).
properties:
application:
description: Application indicates failover behaviors in case
of application failure. If this value is nil, failover is disabled.
If set, the PropagateDeps should be true so that the dependencies
could be migrated along with the application.
properties:
blockPredecessorSeconds:
default: 600
description: BlockPredecessorSeconds represents the period
of time the cluster from which the application was migrated
from can be schedulable again. During the period of BlockPredecessorSeconds,
clusters are forcibly filtered out by the scheduler. If
not specified or the value is zero, the evicted cluster
is schedulable to the application when rescheduling. Defaults
to 600s.
format: int32
type: integer
decisionConditions:
description: 'DecisionConditions indicates the decision conditions
of performing the failover process. Only when all conditions
are met can the failover process be performed. Currently,
DecisionConditions includes several conditions: - TolerationSeconds
(optional) - HealthyState (mandatory)'
properties:
tolerationSeconds:
default: 300
description: TolerationSeconds represents the period of
time Karmada should wait after reaching the desired
state before performing failover process. If not specified,
Karmada will immediately perform failover process. Defaults
to 300s.
format: int32
type: integer
type: object
preConditions:
description: 'PreConditions indicates the preconditions of
the failover process. If specified, only when all conditions
are met can the failover process be started. Currently,
PreConditions includes several conditions: - DelaySeconds
(optional) - HealthyState (optional)'
properties:
delaySeconds:
description: DelaySeconds refers to a period of time after
the control plane collects the status of the application
for the first time. If specified, the failover process
will be started after DelaySeconds is reached. It can
be used simultaneously with HealthyState and does not
affect each other.
format: int32
type: integer
healthyState:
description: HealthyState refers to the healthy status
reported by the Karmada resource interpreter. Valid
option is "Healthy". If specified, the failover process
will be started when the application reaches the healthy
state. It can be used simultaneously with DelaySeconds
and does not affect each other.
type: string
type: object
purgeMode:
default: Graciously
description: PurgeMode represents how to deal with the legacy
applications on the cluster from which the application is
migrated. Valid options are "Immediately", "Graciously"
and "Never". Defaults to "Graciously".
type: string
required:
- decisionConditions
type: object
type: object
gracefulEvictionTasks:
description: 'GracefulEvictionTasks holds the eviction tasks that
are expected to perform the eviction in a graceful way. The intended

View File

@ -102,6 +102,11 @@ type ResourceBindingSpec struct {
// It inherits directly from the associated PropagationPolicy(or ClusterPropagationPolicy).
// +optional
SchedulerName string `json:"schedulerName,omitempty"`
// Failover indicates how Karmada migrates applications in case of failures.
// It inherits directly from the associated PropagationPolicy(or ClusterPropagationPolicy).
// +optional
Failover *policyv1alpha1.FailoverBehavior `json:"failover,omitempty"`
}
// ObjectReference contains enough information to locate the referenced object inside current cluster.
@ -260,6 +265,7 @@ type AggregatedStatusItem struct {
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
Status *runtime.RawExtension `json:"status,omitempty"`
// Applied represents if the resource referencing by ResourceBinding or ClusterResourceBinding
// is successfully applied on the cluster.
// +optional

View File

@ -310,6 +310,11 @@ func (in *ResourceBindingSpec) DeepCopyInto(out *ResourceBindingSpec) {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Failover != nil {
in, out := &in.Failover, &out.Failover
*out = new(v1alpha1.FailoverBehavior)
(*in).DeepCopyInto(*out)
}
return
}

View File

@ -5452,12 +5452,18 @@ func schema_pkg_apis_work_v1alpha2_ResourceBindingSpec(ref common.ReferenceCallb
Format: "",
},
},
"failover": {
SchemaProps: spec.SchemaProps{
Description: "Failover indicates how Karmada migrates applications in case of failures. It inherits directly from the associated PropagationPolicy(or ClusterPropagationPolicy).",
Ref: ref("github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FailoverBehavior"),
},
},
},
Required: []string{"resource"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.Placement", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.BindingSnapshot", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.GracefulEvictionTask", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.ObjectReference", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.ReplicaRequirements", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.TargetCluster"},
"github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.FailoverBehavior", "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1.Placement", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.BindingSnapshot", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.GracefulEvictionTask", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.ObjectReference", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.ReplicaRequirements", "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2.TargetCluster"},
}
}