Skip to content

Commit 62a7e0f

Browse files
committed
*: add remote source from xtrabackup
1 parent 18939ac commit 62a7e0f

20 files changed

+260
-17
lines changed

Dockerfile.sidecar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN set -ex; \
5252
ARG XTRABACKUP_PKG=percona-xtrabackup-24
5353
RUN set -ex; \
5454
apt-get update; \
55-
apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl bc; \
55+
apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl bc openssh-server sshpass;\
5656
wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
5757
dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
5858
apt-get update; \

api/v1alpha1/mysqlcluster_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ type MysqlClusterSpec struct {
113113
// Containing CA (ca.crt) and server cert (tls.crt), server private key (tls.key) for SSL
114114
// +optional
115115
TlsSecretName string `json:"tlsSecretName,omitempty"`
116+
117+
// Bootstraping from remote data source
118+
// +optional
119+
SourceConfig *corev1.SecretProjection `json:"sourceConfig,omitempty"`
116120
}
117121

118122
// ReadOnly define the ReadOnly pods
@@ -345,7 +349,8 @@ const (
345349
// ClusterUpdateState indicates whether the cluster is being updated.
346350
ClusterUpdateState ClusterState = "Updating"
347351
// ClusterReadyState indicates whether all containers in the pod are ready.
348-
ClusterReadyState ClusterState = "Ready"
352+
ClusterReadyState ClusterState = "Ready"
353+
ClusterRemoteCompleted ClusterState = "RemoteCompleted"
349354
// ClusterCloseState indicates whether the cluster is closed.
350355
ClusterCloseState ClusterState = "Closed"
351356
// ClusterScaleInState indicates whether the cluster replicas is decreasing.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/mysqlcluster_conversion.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ func Convert_v1alpha1_MysqlClusterSpec_To_v1beta1_MysqlClusterSpec(in *v1alpha1.
9595
out.DataSource.S3Backup.SecretName = in.BackupSecretName
9696
out.DataSource.RestorePoint = in.RestorePoint
9797
}
98-
98+
if in.SourceConfig != nil {
99+
out.DataSource.Remote.SourceConfig = in.SourceConfig
100+
}
99101
if len(in.NFSServerAddress) != 0 {
100102
ipStr := strings.Split(in.NFSServerAddress, ":")
101103
out.DataSource.RestorePoint = in.RestorePoint
@@ -160,6 +162,9 @@ func Convert_v1beta1_MysqlClusterSpec_To_v1alpha1_MysqlClusterSpec(in *MysqlClus
160162
out.PodPolicy.PriorityClassName = in.PriorityClassName
161163
// in.DataSource in.Standby
162164
out.XenonOpts.EnableAutoRebuild = in.EnableAutoRebuild
165+
if in.DataSource.Remote.SourceConfig != nil {
166+
out.SourceConfig = in.DataSource.Remote.SourceConfig
167+
}
163168
if len(in.DataSource.S3Backup.Name) != 0 {
164169
out.RestoreFrom = in.DataSource.S3Backup.Name
165170
out.BackupSecretName = in.DataSource.S3Backup.SecretName

api/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/mysql-operator/templates/mysql.radondb.com_mysqlclusters.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,53 @@ spec:
22782278
description: RestorePoint is the target date and time to restore data.
22792279
The format is "2006-01-02 15:04:05"
22802280
type: string
2281+
sourceConfig:
2282+
description: Bootstraping from remote data source
2283+
properties:
2284+
items:
2285+
description: If unspecified, each key-value pair in the Data field
2286+
of the referenced Secret will be projected into the volume as
2287+
a file whose name is the key and content is the value. If specified,
2288+
the listed keys will be projected into the specified paths,
2289+
and unlisted keys will not be present. If a key is specified
2290+
which is not present in the Secret, the volume setup will error
2291+
unless it is marked optional. Paths must be relative and may
2292+
not contain the '..' path or start with '..'.
2293+
items:
2294+
description: Maps a string key to a path within a volume.
2295+
properties:
2296+
key:
2297+
description: The key to project.
2298+
type: string
2299+
mode:
2300+
description: 'Optional: mode bits used to set permissions
2301+
on this file. Must be an octal value between 0000 and
2302+
0777 or a decimal value between 0 and 511. YAML accepts
2303+
both octal and decimal values, JSON requires decimal values
2304+
for mode bits. If not specified, the volume defaultMode
2305+
will be used. This might be in conflict with other options
2306+
that affect the file mode, like fsGroup, and the result
2307+
can be other mode bits set.'
2308+
format: int32
2309+
type: integer
2310+
path:
2311+
description: The relative path of the file to map the key
2312+
to. May not be an absolute path. May not contain the path
2313+
element '..'. May not start with the string '..'.
2314+
type: string
2315+
required:
2316+
- key
2317+
- path
2318+
type: object
2319+
type: array
2320+
name:
2321+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
2322+
TODO: Add other useful fields. apiVersion, kind, uid?'
2323+
type: string
2324+
optional:
2325+
description: Specify whether the Secret or its key must be defined
2326+
type: boolean
2327+
type: object
22812328
tlsSecretName:
22822329
description: Containing CA (ca.crt) and server cert (tls.crt), server
22832330
private key (tls.key) for SSL

config/crd/bases/mysql.radondb.com_mysqlclusters.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,53 @@ spec:
22602260
description: RestorePoint is the target date and time to restore data.
22612261
The format is "2006-01-02 15:04:05"
22622262
type: string
2263+
sourceConfig:
2264+
description: Bootstraping from remote data source
2265+
properties:
2266+
items:
2267+
description: If unspecified, each key-value pair in the Data field
2268+
of the referenced Secret will be projected into the volume as
2269+
a file whose name is the key and content is the value. If specified,
2270+
the listed keys will be projected into the specified paths,
2271+
and unlisted keys will not be present. If a key is specified
2272+
which is not present in the Secret, the volume setup will error
2273+
unless it is marked optional. Paths must be relative and may
2274+
not contain the '..' path or start with '..'.
2275+
items:
2276+
description: Maps a string key to a path within a volume.
2277+
properties:
2278+
key:
2279+
description: The key to project.
2280+
type: string
2281+
mode:
2282+
description: 'Optional: mode bits used to set permissions
2283+
on this file. Must be an octal value between 0000 and
2284+
0777 or a decimal value between 0 and 511. YAML accepts
2285+
both octal and decimal values, JSON requires decimal values
2286+
for mode bits. If not specified, the volume defaultMode
2287+
will be used. This might be in conflict with other options
2288+
that affect the file mode, like fsGroup, and the result
2289+
can be other mode bits set.'
2290+
format: int32
2291+
type: integer
2292+
path:
2293+
description: The relative path of the file to map the key
2294+
to. May not be an absolute path. May not contain the path
2295+
element '..'. May not start with the string '..'.
2296+
type: string
2297+
required:
2298+
- key
2299+
- path
2300+
type: object
2301+
type: array
2302+
name:
2303+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
2304+
TODO: Add other useful fields. apiVersion, kind, uid?'
2305+
type: string
2306+
optional:
2307+
description: Specify whether the Secret or its key must be defined
2308+
type: boolean
2309+
type: object
22632310
tlsSecretName:
22642311
description: Containing CA (ca.crt) and server cert (tls.crt), server
22652312
private key (tls.key) for SSL

config/samples/mysql_v1beta1_mysqlcluster.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ spec:
1414
S3backup:
1515
name: ""
1616
secretName: ""
17-
remote: {}
17+
remote:
18+
# sourceConfig:
19+
# name: remotesecret
20+
# items:
21+
# - key: passwd
22+
# path: passwd
23+
# - key: host
24+
# path: host
25+
1826
image: percona/percona-server:8.0.25
1927
imagePullPolicy: Always
2028
logOpts:

docs/en-us/backup_and_restoration_nfs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ You can use `ClusterIp` to perform NFS backup. The cluster IP address in the exa
4747
### 1. Configure the NFS server address
4848

4949
```yaml
50-
# config/samples/mysql_v1alpha1_backup.yaml
50+
# config/samples/mysql_v1beta1_backup.yaml
5151
nfsServerAddress: "10.96.253.82"
5252
```
5353
5454
### 2. Create a backup
5555
```shell
56-
kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml
56+
kubectl apply -f config/samples/mysql_v1beta1_backup.yaml
5757
```
5858
> Note: The backup CRD and MySQL cluster CRD must be in the same namespace.
5959
@@ -67,7 +67,7 @@ index.html initbackup sample_2022419101946
6767

6868
## Restore the cluster from the NFS backup
6969

70-
Configure the `nfsServerAddress` attribute to the NFS server address in the `mysql_v1alpha1_cluster.yaml` file.
70+
Configure the `nfsServerAddress` attribute to the NFS server address in the `mysql_v1alpha1_cluster.yaml` file or `mysql_v1beta1_cluster.yaml` file.
7171

7272
```yaml
7373
...

docs/en-us/backup_and_restoration_s3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ kubectl create -f config/samples/backup_secret.yaml
4646
```
4747
4848
### Step 2: Configure the backup Secret for the Operator cluster
49-
Configure the `backupSecretName` property in `mysql_v1alpha1_mysqlcluster.yaml`, for example, `sample-backup-secre`.
49+
Configure the `backupSecretName` property in `mysql_v1beta1_mysqlcluster.yaml`, for example, `sample-backup-secre`.
5050
5151
```yaml
5252
spec:

0 commit comments

Comments
 (0)