-
Notifications
You must be signed in to change notification settings - Fork 88
*: support backup/restore with NFS #148 #232
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,5 +5,7 @@ metadata: | |
| spec: | ||
| # Add fields here | ||
| image: radondb/mysql-sidecar:latest | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mysql57-sidecar:v2.2.0 |
||
| # hostname if empty, use the leader as hostname | ||
| hostname: sample-mysql-0 | ||
| clustname: sample | ||
| # BackupToNFS: "IP of NFS server" | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
runkecheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 hidden or 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 | ||
acekingke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| > 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 | ||
acekingke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| `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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.