Skip to content

Commit 8b14046

Browse files
authored
Merge pull request #6610 from XiShanYongYe-Chang/add-cluster-failover-behavior-api
Introduced `spec.failover.cluster` to the PropagationPolicy API for application-level cluster failover
2 parents 5afc4ec + 8fafe59 commit 8b14046

File tree

8 files changed

+423
-3
lines changed

8 files changed

+423
-3
lines changed

api/openapi-spec/swagger.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19282,6 +19282,20 @@
1928219282
}
1928319283
}
1928419284
},
19285+
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterFailoverBehavior": {
19286+
"description": "ClusterFailoverBehavior indicates cluster failover behaviors.",
19287+
"type": "object",
19288+
"properties": {
19289+
"purgeMode": {
19290+
"description": "PurgeMode represents how to deal with the legacy applications on the cluster from which the application is migrated. Valid options are \"Directly\", \"Gracefully\". Defaults to \"Gracefully\".",
19291+
"type": "string"
19292+
},
19293+
"statePreservation": {
19294+
"description": "StatePreservation defines the policy for preserving and restoring state data during failover events for stateful applications.\n\nWhen an application fails over from one cluster to another, this policy enables the extraction of critical data from the original resource configuration. Upon successful migration, the extracted data is then re-injected into the new resource, ensuring that the application can resume operation with its previous state intact. This is particularly useful for stateful applications where maintaining data consistency across failover events is crucial. If not specified, means no state data will be preserved.\n\nNote: This requires the StatefulFailoverInjection feature gate to be enabled, which is alpha.",
19295+
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.StatePreservation"
19296+
}
19297+
}
19298+
},
1928519299
"com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterOverridePolicy": {
1928619300
"description": "ClusterOverridePolicy represents the cluster-wide policy that overrides a group of resources to one or more clusters.",
1928719301
"type": "object",
@@ -19616,6 +19630,10 @@
1961619630
"application": {
1961719631
"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.",
1961819632
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ApplicationFailoverBehavior"
19633+
},
19634+
"cluster": {
19635+
"description": "Cluster indicates failover behaviors in case of cluster failure. If this value is nil, the failover behavior in case of cluster failure will be controlled by the controller's no-execute-taint-eviction-purge-mode parameter. If set, the failover behavior in case of cluster failure will be defined by this value.",
19636+
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.ClusterFailoverBehavior"
1961919637
}
1962019638
}
1962119639
},

charts/karmada/_crds/bases/policy/policy.karmada.io_clusterpropagationpolicies.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,83 @@ spec:
226226
required:
227227
- decisionConditions
228228
type: object
229+
cluster:
230+
description: |-
231+
Cluster indicates failover behaviors in case of cluster failure.
232+
If this value is nil, the failover behavior in case of cluster failure
233+
will be controlled by the controller's no-execute-taint-eviction-purge-mode
234+
parameter.
235+
If set, the failover behavior in case of cluster failure will be defined
236+
by this value.
237+
properties:
238+
purgeMode:
239+
default: Gracefully
240+
description: |-
241+
PurgeMode represents how to deal with the legacy applications on the
242+
cluster from which the application is migrated.
243+
Valid options are "Directly", "Gracefully".
244+
Defaults to "Gracefully".
245+
enum:
246+
- Directly
247+
- Gracefully
248+
type: string
249+
statePreservation:
250+
description: |-
251+
StatePreservation defines the policy for preserving and restoring state data
252+
during failover events for stateful applications.
253+
254+
When an application fails over from one cluster to another, this policy enables
255+
the extraction of critical data from the original resource configuration.
256+
Upon successful migration, the extracted data is then re-injected into the new
257+
resource, ensuring that the application can resume operation with its previous
258+
state intact.
259+
This is particularly useful for stateful applications where maintaining data
260+
consistency across failover events is crucial.
261+
If not specified, means no state data will be preserved.
262+
263+
Note: This requires the StatefulFailoverInjection feature gate to be enabled,
264+
which is alpha.
265+
properties:
266+
rules:
267+
description: |-
268+
Rules contains a list of StatePreservationRule configurations.
269+
Each rule specifies a JSONPath expression targeting specific pieces of
270+
state data to be preserved during failover events. An AliasLabelName is associated
271+
with each rule, serving as a label key when the preserved data is passed
272+
to the new cluster.
273+
items:
274+
description: |-
275+
StatePreservationRule defines a single rule for state preservation.
276+
It includes a JSONPath expression and an alias name that will be used
277+
as a label key when passing state information to the new cluster.
278+
properties:
279+
aliasLabelName:
280+
description: |-
281+
AliasLabelName is the name that will be used as a label key when the preserved
282+
data is passed to the new cluster. This facilitates the injection of the
283+
preserved state back into the application resources during recovery.
284+
type: string
285+
jsonPath:
286+
description: |-
287+
JSONPath is the JSONPath template used to identify the state data
288+
to be preserved from the original resource configuration.
289+
The JSONPath syntax follows the Kubernetes specification:
290+
https://kubernetes.io/docs/reference/kubectl/jsonpath/
291+
292+
Note: The JSONPath expression will start searching from the "status" field of
293+
the API resource object by default. For example, to extract the "availableReplicas"
294+
from a Deployment, the JSONPath expression should be "{.availableReplicas}", not
295+
"{.status.availableReplicas}".
296+
type: string
297+
required:
298+
- aliasLabelName
299+
- jsonPath
300+
type: object
301+
type: array
302+
required:
303+
- rules
304+
type: object
305+
type: object
229306
type: object
230307
placement:
231308
description: Placement represents the rule for select clusters to

charts/karmada/_crds/bases/policy/policy.karmada.io_propagationpolicies.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,83 @@ spec:
223223
required:
224224
- decisionConditions
225225
type: object
226+
cluster:
227+
description: |-
228+
Cluster indicates failover behaviors in case of cluster failure.
229+
If this value is nil, the failover behavior in case of cluster failure
230+
will be controlled by the controller's no-execute-taint-eviction-purge-mode
231+
parameter.
232+
If set, the failover behavior in case of cluster failure will be defined
233+
by this value.
234+
properties:
235+
purgeMode:
236+
default: Gracefully
237+
description: |-
238+
PurgeMode represents how to deal with the legacy applications on the
239+
cluster from which the application is migrated.
240+
Valid options are "Directly", "Gracefully".
241+
Defaults to "Gracefully".
242+
enum:
243+
- Directly
244+
- Gracefully
245+
type: string
246+
statePreservation:
247+
description: |-
248+
StatePreservation defines the policy for preserving and restoring state data
249+
during failover events for stateful applications.
250+
251+
When an application fails over from one cluster to another, this policy enables
252+
the extraction of critical data from the original resource configuration.
253+
Upon successful migration, the extracted data is then re-injected into the new
254+
resource, ensuring that the application can resume operation with its previous
255+
state intact.
256+
This is particularly useful for stateful applications where maintaining data
257+
consistency across failover events is crucial.
258+
If not specified, means no state data will be preserved.
259+
260+
Note: This requires the StatefulFailoverInjection feature gate to be enabled,
261+
which is alpha.
262+
properties:
263+
rules:
264+
description: |-
265+
Rules contains a list of StatePreservationRule configurations.
266+
Each rule specifies a JSONPath expression targeting specific pieces of
267+
state data to be preserved during failover events. An AliasLabelName is associated
268+
with each rule, serving as a label key when the preserved data is passed
269+
to the new cluster.
270+
items:
271+
description: |-
272+
StatePreservationRule defines a single rule for state preservation.
273+
It includes a JSONPath expression and an alias name that will be used
274+
as a label key when passing state information to the new cluster.
275+
properties:
276+
aliasLabelName:
277+
description: |-
278+
AliasLabelName is the name that will be used as a label key when the preserved
279+
data is passed to the new cluster. This facilitates the injection of the
280+
preserved state back into the application resources during recovery.
281+
type: string
282+
jsonPath:
283+
description: |-
284+
JSONPath is the JSONPath template used to identify the state data
285+
to be preserved from the original resource configuration.
286+
The JSONPath syntax follows the Kubernetes specification:
287+
https://kubernetes.io/docs/reference/kubectl/jsonpath/
288+
289+
Note: The JSONPath expression will start searching from the "status" field of
290+
the API resource object by default. For example, to extract the "availableReplicas"
291+
from a Deployment, the JSONPath expression should be "{.availableReplicas}", not
292+
"{.status.availableReplicas}".
293+
type: string
294+
required:
295+
- aliasLabelName
296+
- jsonPath
297+
type: object
298+
type: array
299+
required:
300+
- rules
301+
type: object
302+
type: object
226303
type: object
227304
placement:
228305
description: Placement represents the rule for select clusters to

charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,83 @@ spec:
583583
required:
584584
- decisionConditions
585585
type: object
586+
cluster:
587+
description: |-
588+
Cluster indicates failover behaviors in case of cluster failure.
589+
If this value is nil, the failover behavior in case of cluster failure
590+
will be controlled by the controller's no-execute-taint-eviction-purge-mode
591+
parameter.
592+
If set, the failover behavior in case of cluster failure will be defined
593+
by this value.
594+
properties:
595+
purgeMode:
596+
default: Gracefully
597+
description: |-
598+
PurgeMode represents how to deal with the legacy applications on the
599+
cluster from which the application is migrated.
600+
Valid options are "Directly", "Gracefully".
601+
Defaults to "Gracefully".
602+
enum:
603+
- Directly
604+
- Gracefully
605+
type: string
606+
statePreservation:
607+
description: |-
608+
StatePreservation defines the policy for preserving and restoring state data
609+
during failover events for stateful applications.
610+
611+
When an application fails over from one cluster to another, this policy enables
612+
the extraction of critical data from the original resource configuration.
613+
Upon successful migration, the extracted data is then re-injected into the new
614+
resource, ensuring that the application can resume operation with its previous
615+
state intact.
616+
This is particularly useful for stateful applications where maintaining data
617+
consistency across failover events is crucial.
618+
If not specified, means no state data will be preserved.
619+
620+
Note: This requires the StatefulFailoverInjection feature gate to be enabled,
621+
which is alpha.
622+
properties:
623+
rules:
624+
description: |-
625+
Rules contains a list of StatePreservationRule configurations.
626+
Each rule specifies a JSONPath expression targeting specific pieces of
627+
state data to be preserved during failover events. An AliasLabelName is associated
628+
with each rule, serving as a label key when the preserved data is passed
629+
to the new cluster.
630+
items:
631+
description: |-
632+
StatePreservationRule defines a single rule for state preservation.
633+
It includes a JSONPath expression and an alias name that will be used
634+
as a label key when passing state information to the new cluster.
635+
properties:
636+
aliasLabelName:
637+
description: |-
638+
AliasLabelName is the name that will be used as a label key when the preserved
639+
data is passed to the new cluster. This facilitates the injection of the
640+
preserved state back into the application resources during recovery.
641+
type: string
642+
jsonPath:
643+
description: |-
644+
JSONPath is the JSONPath template used to identify the state data
645+
to be preserved from the original resource configuration.
646+
The JSONPath syntax follows the Kubernetes specification:
647+
https://kubernetes.io/docs/reference/kubectl/jsonpath/
648+
649+
Note: The JSONPath expression will start searching from the "status" field of
650+
the API resource object by default. For example, to extract the "availableReplicas"
651+
from a Deployment, the JSONPath expression should be "{.availableReplicas}", not
652+
"{.status.availableReplicas}".
653+
type: string
654+
required:
655+
- aliasLabelName
656+
- jsonPath
657+
type: object
658+
type: array
659+
required:
660+
- rules
661+
type: object
662+
type: object
586663
type: object
587664
gracefulEvictionTasks:
588665
description: |-

0 commit comments

Comments
 (0)