Skip to content

Commit 8b28e45

Browse files
authored
Merge pull request radondb#454 from runkecheng/feature_backup_nfs
*:Simplify the use of NFS backup.
2 parents ebb0452 + 6845255 commit 8b28e45

18 files changed

+168
-198
lines changed

api/v1alpha1/backup_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ type BackupSpec struct {
3838
// If is empty, is use leader HostName
3939
HostName string `json:"hostname,omitempty"`
4040

41-
// Represents the name of backup to NFS
41+
// Represents the ip address of the nfs server.
4242
// +optional
43-
BackupToNFS string `json:"BackupToNFS,omitempty"`
43+
NFSServerAddress string `json:"nfsServerAddress,omitempty"`
4444

4545
// ClusterName represents the cluster name to backup
4646
ClusterName string `json:"clustname"`

api/v1alpha1/mysqlcluster_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ type MysqlClusterSpec struct {
7878
// +optional
7979
BackupSecretName string `json:"backupSecretName,omitempty"`
8080

81-
// Represents the name of the cluster restore from backup path
81+
// Represents the name of the cluster restore from backup path.
8282
// +optional
8383
RestoreFrom string `json:"restoreFrom,omitempty"`
8484

8585
// Represents NFS ip address where cluster restore from.
8686
// +optional
87-
RestoreFromNFS string `json:"restoreFromNFS,omitempty"`
87+
NFSServerAddress string `json:"nfsServerAddress,omitempty"`
8888
}
8989

9090
// MysqlOpts defines the options of MySQL container.

backup/syncer/job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ func (s *jobSyncer) ensurePodSpec(in corev1.PodSpec) corev1.PodSpec {
117117
in.Containers[0].Name = utils.ContainerBackupName
118118
in.Containers[0].Image = fmt.Sprintf("%s%s", mysqlcluster.GetPrefixFromEnv(), s.backup.Spec.Image)
119119

120-
if len(s.backup.Spec.BackupToNFS) != 0 {
120+
if len(s.backup.Spec.NFSServerAddress) != 0 {
121121
// add volumn about pvc
122122
in.Volumes = []corev1.Volume{
123123
{
124124
Name: utils.XtrabackupPV,
125125
VolumeSource: corev1.VolumeSource{
126126
NFS: &corev1.NFSVolumeSource{
127-
Server: s.backup.Spec.BackupToNFS,
127+
Server: s.backup.Spec.NFSServerAddress,
128128
Path: "/",
129129
},
130130
},

charts/mysql-operator/crds/mysql.radondb.com_backups.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ spec:
3636
spec:
3737
description: BackupSpec defines the desired state of Backup
3838
properties:
39-
BackupToNFS:
40-
description: Represents the name of backup to NFS
41-
type: string
4239
clustname:
4340
description: ClusterName represents the cluster name to backup
4441
type: string
@@ -55,6 +52,9 @@ spec:
5552
default: radondb/mysql57-sidecar:v2.2.0
5653
description: To specify the image that will be used for sidecar container.
5754
type: string
55+
nfsServerAddress:
56+
description: Represents the ip address of the nfs server.
57+
type: string
5858
required:
5959
- clustname
6060
type: object

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ spec:
215215
Based on this version the operator can take decisions which features
216216
can be used.'
217217
type: string
218+
nfsServerAddress:
219+
description: Represents NFS ip address where cluster restore from.
220+
type: string
218221
persistence:
219222
default:
220223
accessModes:
@@ -1243,10 +1246,7 @@ spec:
12431246
type: integer
12441247
restoreFrom:
12451248
description: Represents the name of the cluster restore from backup
1246-
path
1247-
type: string
1248-
restoreFromNFS:
1249-
description: Represents NFS ip address where cluster restore from.
1249+
path.
12501250
type: string
12511251
xenonOpts:
12521252
default:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ spec:
3636
spec:
3737
description: BackupSpec defines the desired state of Backup
3838
properties:
39-
BackupToNFS:
40-
description: Represents the name of backup to NFS
41-
type: string
4239
clustname:
4340
description: ClusterName represents the cluster name to backup
4441
type: string
@@ -55,6 +52,9 @@ spec:
5552
default: radondb/mysql57-sidecar:v2.2.0
5653
description: To specify the image that will be used for sidecar container.
5754
type: string
55+
nfsServerAddress:
56+
description: Represents the ip address of the nfs server.
57+
type: string
5858
required:
5959
- clustname
6060
type: object

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ spec:
215215
Based on this version the operator can take decisions which features
216216
can be used.'
217217
type: string
218+
nfsServerAddress:
219+
description: Represents NFS ip address where cluster restore from.
220+
type: string
218221
persistence:
219222
default:
220223
accessModes:
@@ -1243,10 +1246,7 @@ spec:
12431246
type: integer
12441247
restoreFrom:
12451248
description: Represents the name of the cluster restore from backup
1246-
path
1247-
type: string
1248-
restoreFromNFS:
1249-
description: Represents NFS ip address where cluster restore from.
1249+
path.
12501250
type: string
12511251
xenonOpts:
12521252
default:

config/samples/mysql_v1alpha1_backup.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ metadata:
44
name: backup-sample
55
spec:
66
# Add fields here
7-
image: radondb/mysql-sidecar:latest
7+
image: radondb/mysql57-sidecar:v2.2.0
88
# hostname if empty, use the leader as hostname
99
hostname: sample-mysql-0
1010
clustname: sample
11-
# BackupToNFS: "IP of NFS server"
11+
# nfsServerAddress: ""

config/samples/mysql_v1alpha1_mysqlcluster.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ spec:
1515
# restoreFrom:
1616

1717
# Restore from NFS, uncomment below and set the ip of NFS server
18-
# such as restoreFromNFS: "10.233.55.172"
19-
# restoreFromNFS:
18+
# such as nfsServerAddress: "10.233.55.172"
19+
# nfsServerAddress:
2020
mysqlOpts:
2121
rootPassword: "RadonDB@123"
2222
rootHost: localhost
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
apiVersion: storage.k8s.io/v1
22
kind: StorageClass
33
metadata:
4-
annotations:
5-
name: manual
4+
name: radondb-nfs-hostpath
65
provisioner: kubernetes.io/no-provisioner
76
reclaimPolicy: Retain
87
volumeBindingMode: WaitForFirstConsumer
@@ -11,11 +10,11 @@ volumeBindingMode: WaitForFirstConsumer
1110
apiVersion: v1
1211
kind: PersistentVolume
1312
metadata:
14-
name: backup-pv-volume
13+
name: radondb-nfs-pv
1514
labels:
1615
type: local
1716
spec:
18-
storageClassName: manual
17+
storageClassName: radondb-nfs-hostpath
1918
# you can set affinity ,for example:
2019
# nodeAffinity:
2120
# required:
@@ -26,8 +25,21 @@ spec:
2625
# values:
2726
# - node2
2827
capacity:
29-
storage: 40Gi
28+
storage: 30Gi
3029
accessModes:
3130
- ReadWriteOnce
3231
hostPath:
33-
path: "/mnt/backup"
32+
path: "/mnt/radondb-nfs-backup"
33+
---
34+
35+
apiVersion: v1
36+
kind: PersistentVolumeClaim
37+
metadata:
38+
name: radondb-nfs-pvc
39+
spec:
40+
storageClassName: radondb-nfs-hostpath
41+
accessModes:
42+
- ReadWriteOnce
43+
resources:
44+
requests:
45+
storage: 30Gi

0 commit comments

Comments
 (0)