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

*:Simplify the use of NFS backup. #454

Merged
merged 2 commits into from
Apr 20, 2022
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
4 changes: 2 additions & 2 deletions api/v1alpha1/backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type BackupSpec struct {
// If is empty, is use leader HostName
HostName string `json:"hostname,omitempty"`

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

// ClusterName represents the cluster name to backup
ClusterName string `json:"clustname"`
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ type MysqlClusterSpec struct {
// +optional
BackupSecretName string `json:"backupSecretName,omitempty"`

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

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

// MysqlOpts defines the options of MySQL container.
Expand Down
4 changes: 2 additions & 2 deletions backup/syncer/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ func (s *jobSyncer) ensurePodSpec(in corev1.PodSpec) corev1.PodSpec {
in.Containers[0].Name = utils.ContainerBackupName
in.Containers[0].Image = fmt.Sprintf("%s%s", mysqlcluster.GetPrefixFromEnv(), s.backup.Spec.Image)

if len(s.backup.Spec.BackupToNFS) != 0 {
if len(s.backup.Spec.NFSServerAddress) != 0 {
// add volumn about pvc
in.Volumes = []corev1.Volume{
{
Name: utils.XtrabackupPV,
VolumeSource: corev1.VolumeSource{
NFS: &corev1.NFSVolumeSource{
Server: s.backup.Spec.BackupToNFS,
Server: s.backup.Spec.NFSServerAddress,
Path: "/",
},
},
Expand Down
6 changes: 3 additions & 3 deletions charts/mysql-operator/crds/mysql.radondb.com_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ spec:
spec:
description: BackupSpec defines the desired state of Backup
properties:
BackupToNFS:
description: Represents the name of backup to NFS
type: string
clustname:
description: ClusterName represents the cluster name to backup
type: string
Expand All @@ -55,6 +52,9 @@ spec:
default: radondb/mysql57-sidecar:v2.2.0
description: To specify the image that will be used for sidecar container.
type: string
nfsServerAddress:
description: Represents the ip address of the nfs server.
type: string
required:
- clustname
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ spec:
Based on this version the operator can take decisions which features
can be used.'
type: string
nfsServerAddress:
description: Represents NFS ip address where cluster restore from.
type: string
persistence:
default:
accessModes:
Expand Down Expand Up @@ -1243,10 +1246,7 @@ spec:
type: integer
restoreFrom:
description: Represents the name of the cluster restore from backup
path
type: string
restoreFromNFS:
description: Represents NFS ip address where cluster restore from.
path.
type: string
xenonOpts:
default:
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/mysql.radondb.com_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ spec:
spec:
description: BackupSpec defines the desired state of Backup
properties:
BackupToNFS:
description: Represents the name of backup to NFS
type: string
clustname:
description: ClusterName represents the cluster name to backup
type: string
Expand All @@ -55,6 +52,9 @@ spec:
default: radondb/mysql57-sidecar:v2.2.0
description: To specify the image that will be used for sidecar container.
type: string
nfsServerAddress:
description: Represents the ip address of the nfs server.
type: string
required:
- clustname
type: object
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/mysql.radondb.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ spec:
Based on this version the operator can take decisions which features
can be used.'
type: string
nfsServerAddress:
description: Represents NFS ip address where cluster restore from.
type: string
persistence:
default:
accessModes:
Expand Down Expand Up @@ -1243,10 +1246,7 @@ spec:
type: integer
restoreFrom:
description: Represents the name of the cluster restore from backup
path
type: string
restoreFromNFS:
description: Represents NFS ip address where cluster restore from.
path.
type: string
xenonOpts:
default:
Expand Down
4 changes: 2 additions & 2 deletions config/samples/mysql_v1alpha1_backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: backup-sample
spec:
# Add fields here
image: radondb/mysql-sidecar:latest
image: radondb/mysql57-sidecar:v2.2.0
# hostname if empty, use the leader as hostname
hostname: sample-mysql-0
clustname: sample
# BackupToNFS: "IP of NFS server"
# nfsServerAddress: ""
4 changes: 2 additions & 2 deletions config/samples/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ spec:
# restoreFrom:

# Restore from NFS, uncomment below and set the ip of NFS server
# such as restoreFromNFS: "10.233.55.172"
# restoreFromNFS:
# such as nfsServerAddress: "10.233.55.172"
# nfsServerAddress:
mysqlOpts:
rootPassword: "RadonDB@123"
rootHost: localhost
Expand Down
24 changes: 18 additions & 6 deletions config/samples/pv-volume.yaml → config/samples/nfs_pv.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
name: manual
name: radondb-nfs-hostpath
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
Expand All @@ -11,11 +10,11 @@ volumeBindingMode: WaitForFirstConsumer
apiVersion: v1
kind: PersistentVolume
metadata:
name: backup-pv-volume
name: radondb-nfs-pv
labels:
type: local
spec:
storageClassName: manual
storageClassName: radondb-nfs-hostpath
# you can set affinity ,for example:
# nodeAffinity:
# required:
Expand All @@ -26,8 +25,21 @@ spec:
# values:
# - node2
capacity:
storage: 40Gi
storage: 30Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/backup"
path: "/mnt/radondb-nfs-backup"
---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: radondb-nfs-pvc
spec:
storageClassName: radondb-nfs-hostpath
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
32 changes: 0 additions & 32 deletions config/samples/nfs_rc.yaml

This file was deleted.

36 changes: 35 additions & 1 deletion config/samples/nfs_server.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: radondb-nfs-server
spec:
replicas: 1
selector:
role: nfs-server
template:
metadata:
labels:
role: nfs-server
spec:
containers:
- name: nfs-server
## TODO: radondb/volume-nfs:0.8
image: gcr.azk8s.cn/google_containers/volume-nfs:0.8
ports:
- name: nfs
containerPort: 2049
- name: mountd
containerPort: 20048
- name: rpcbind
containerPort: 111
securityContext:
privileged: true
volumeMounts:
- mountPath: /exports
name: nfs-export-fast
volumes:
- name: nfs-export-fast
persistentVolumeClaim:
claimName: radondb-nfs-pvc
---
kind: Service
apiVersion: v1
metadata:
name: nfs-server
name: radondb-nfs-server
spec:
ports:
- name: nfs
Expand Down
11 changes: 0 additions & 11 deletions config/samples/pv-claim.yml

This file was deleted.

64 changes: 0 additions & 64 deletions docs/deploy_backup_restore_nfs.md

This file was deleted.

Loading