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

feat: support filtering backup target pods by the alternative label selector #7831

Merged
merged 11 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions apis/apps/v1alpha1/backuppolicytemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ type TargetInstance struct {
// the `strategy` field below.
Role string `json:"role"`

// Specifies the fallback role to select one replica for backup, this only takes effect when the
// `strategy` field below is set to `Any`.
//
// +optional
FallbackRole string `json:"fallbackRole,omitempty"`

// If `backupPolicy.componentDefs` is set, this field is required to specify the system account name.
// This account must match one listed in `componentDefinition.spec.systemAccounts[*].name`.
// The corresponding secret created by this account is used to connect to the database.
Expand Down
6 changes: 6 additions & 0 deletions apis/dataprotection/v1alpha1/backuppolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ type PodSelector struct {
// labelsSelector is the label selector to filter the target pods.
*metav1.LabelSelector `json:",inline"`

// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
// This only takes effect when the `strategy` field below is set to `Any`.
//
// +optional
FallbackLabelSelector *metav1.LabelSelector `json:"fallbackLabelSelector,omitempty"`

// Specifies the strategy to select the target pod when multiple pods are selected.
// Valid values are:
//
Expand Down
5 changes: 5 additions & 0 deletions apis/dataprotection/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ spec:
If not specified, the default key "username" is used.
type: string
type: object
fallbackRole:
description: |-
Specifies the fallback role to select one replica for backup, this only takes effect when the
`strategy` field below is set to `Any`.
type: string
name:
description: |-
Specifies a mandatory and unique identifier for each target when using the "targets" field.
Expand All @@ -427,6 +432,53 @@ spec:
description: Used to find the target pod. The volumes
of the target pod will be backed up.
properties:
fallbackLabelSelector:
description: |-
fallbackLabelSelector is used to filter available pods when the labelSelector fails.
This only takes effect when the `strategy` field below is set to `Any`.
properties:
matchExpressions:
description: matchExpressions is a list of
label selector requirements. The requirements
are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that
the selector applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
matchExpressions:
description: matchExpressions is a list of label
selector requirements. The requirements are
Expand Down Expand Up @@ -689,6 +741,53 @@ spec:
description: Used to find the target pod. The volumes
of the target pod will be backed up.
properties:
fallbackLabelSelector:
description: |-
fallbackLabelSelector is used to filter available pods when the labelSelector fails.
This only takes effect when the `strategy` field below is set to `Any`.
properties:
matchExpressions:
description: matchExpressions is a list
of label selector requirements. The requirements
are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key
that the selector applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
matchExpressions:
description: matchExpressions is a list of label
selector requirements. The requirements are
Expand Down Expand Up @@ -918,6 +1017,11 @@ spec:
If not specified, the default key "username" is used.
type: string
type: object
fallbackRole:
description: |-
Specifies the fallback role to select one replica for backup, this only takes effect when the
`strategy` field below is set to `Any`.
type: string
role:
description: |-
Specifies the role to select one or more replicas for backup.
Expand Down
Loading
Loading