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

// Specifies the alternative role to select one or more replicas for backup.
//
// +optional
AlternateRole string `json:"alternateRole"`
gnolong marked this conversation as resolved.
Show resolved Hide resolved

// 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
5 changes: 5 additions & 0 deletions apis/dataprotection/v1alpha1/backuppolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ type PodSelector struct {
// labelsSelector is the label selector to filter the target pods.
*metav1.LabelSelector `json:",inline"`

// alternateLabelSelector is used to filter available pods when the labelSelector fails.
//
// +optional
AlternateLabelSelector *metav1.LabelSelector `json:"alternateLabelSelector,omitempty"`
gnolong marked this conversation as resolved.
Show resolved Hide resolved
gnolong marked this conversation as resolved.
Show resolved Hide resolved

// 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.

102 changes: 102 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ spec:
If `backupPolicy.componentDefRef` (a legacy and deprecated API) is set, the secret defined in
`clusterDefinition.spec.ConnectionCredential` is used instead.
type: string
alternateRole:
description: Specifies the alternative role to select
one or more replicas for backup.
type: string
connectionCredential:
description: Specifies the connection credential to
connect to the target database cluster.
Expand Down Expand Up @@ -427,6 +431,53 @@ spec:
description: Used to find the target pod. The volumes
of the target pod will be backed up.
properties:
alternateLabelSelector:
description: alternateLabelSelector is used to
filter available pods when the labelSelector
fails.
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 +740,53 @@ spec:
description: Used to find the target pod. The volumes
of the target pod will be backed up.
properties:
alternateLabelSelector:
description: alternateLabelSelector is used
to filter available pods when the labelSelector
fails.
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 @@ -894,6 +992,10 @@ spec:
If `backupPolicy.componentDefRef` (a legacy and deprecated API) is set, the secret defined in
`clusterDefinition.spec.ConnectionCredential` is used instead.
type: string
alternateRole:
description: Specifies the alternative role to select one
or more replicas for backup.
type: string
connectionCredentialKey:
description: |-
Specifies the keys of the connection credential secret defined in `clusterDefinition.spec.ConnectionCredential`.
Expand Down
Loading
Loading