-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from acekingke/backupForNFS
*: support backup/restore with NFS #148
- Loading branch information
Showing
28 changed files
with
407 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: v1 | ||
kind: ReplicationController | ||
metadata: | ||
name: nfs-server | ||
spec: | ||
replicas: 1 | ||
selector: | ||
role: nfs-server | ||
template: | ||
metadata: | ||
labels: | ||
role: nfs-server | ||
spec: | ||
containers: | ||
- name: nfs-server | ||
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: backup-pv-claim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: nfs-server | ||
spec: | ||
ports: | ||
- name: nfs | ||
port: 2049 | ||
- name: mountd | ||
port: 20048 | ||
- name: rpcbind | ||
port: 111 | ||
selector: | ||
role: nfs-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: backup-pv-claim | ||
spec: | ||
storageClassName: manual | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 30Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
annotations: | ||
name: manual | ||
provisioner: kubernetes.io/no-provisioner | ||
reclaimPolicy: Retain | ||
volumeBindingMode: WaitForFirstConsumer | ||
--- | ||
|
||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: backup-pv-volume | ||
labels: | ||
type: local | ||
spec: | ||
storageClassName: manual | ||
# you can set affinity ,for example: | ||
# nodeAffinity: | ||
# required: | ||
# nodeSelectorTerms: | ||
# - matchExpressions: | ||
# - key: kubernetes.io/hostname | ||
# operator: In | ||
# values: | ||
# - node2 | ||
capacity: | ||
storage: 40Gi | ||
accessModes: | ||
- ReadWriteOnce | ||
hostPath: | ||
path: "/mnt/backup" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# mysql-operator | ||
|
||
## Quickstart for NFS backup | ||
### Create NFS server | ||
First create your PVC, such as "neosan1", | ||
Or use local storage pvc, see `config/sample/pv-claim.yaml` | ||
and `pv-volume.yaml` for more details. | ||
Then create NFS server, such as "nfs-server", | ||
```yaml | ||
fill it to `config/samples/nfs_rc.yaml ` | ||
```yaml | ||
... | ||
volumes: | ||
- name: nfs-export-fast | ||
persistentVolumeClaim: | ||
claimName: neosan1 // or backup-pv-claim | ||
``` | ||
```shell | ||
# create the nfs pod | ||
kubectl apply -f config/samples/nfs_rc.yaml | ||
# create the nfs service | ||
kubectl apply -f config/samples/nfs_server.yaml | ||
``` | ||
if create the nfs server successful, get the then: | ||
|
||
## config `mysql_v1alpha1_backup.yaml ` and backup | ||
Add field in `mysql_v1alpha1_backup.yaml ` as follow: | ||
```yaml | ||
BackupToNFS: "IP of NFS server" | ||
``` | ||
use command as follow to backup | ||
```shell | ||
kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml | ||
``` | ||
> Notice: backup cr and mysqlcluster cr must be in the same namespace. | ||
## Restore cluster from exist NFS backup | ||
first, configure the `mysql_v1alpha1_cluster.yaml`, uncomment the `restoreFromNFS` field: | ||
```yaml | ||
.... | ||
restoreFrom: "sample_202196152239" | ||
restoreFromNFS : 10.96.253.82 | ||
``` | ||
`sample_202196152239` is the nfs server backup path, change it to yours. | ||
the `10.96.253.82` is the NFS server ip, change it to yours. | ||
|
||
> Notice: you can find the `sample_202196152239` in the nfs_server pod, at `/exports` path | ||
or find it in node `/mnt/backup` path if you use the local pesistent volume with `sample/pv-volume.yaml`. | ||
|
||
use command as follow to create cluster from NFS server backup copy: | ||
|
||
## build your own image | ||
such as : | ||
``` | ||
docker build -f Dockerfile.sidecar -t acekingke/sidecar:0.1 . && docker push acekingke/sidecar:0.1 | ||
docker build -t acekingke/controller:0.1 . && docker push acekingke/controller:0.1 | ||
``` | ||
you can replace acekingke/sidecar:0.1 with your own tag | ||
|
||
## deploy your own manager | ||
```shell | ||
make manifests | ||
make install | ||
make deploy IMG=acekingke/controller:0.1 KUSTOMIZE=~/radondb-mysql-kubernetes/bin/kustomize | ||
``` |
Oops, something went wrong.