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

chart: support NFS backup. #455

Merged
merged 1 commit 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
105 changes: 105 additions & 0 deletions charts/mysql-operator/templates/nfs_backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{{- with .Values.nfsBackup -}}
## installServer & (specifiedPVC | createLocalPV)
{{- if (and .installServer (or (not (empty .volume.specifiedPVC)) .volume.createLocalPV )) -}}
{{- if (and (empty .volume.specifiedPVC) .volume.createLocalPV) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: radondb-nfs-pvc
spec:
storageClassName: radondb-nfs-hostpath
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .volume.localPVCapacity }}
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
name: radondb-nfs-hostpath
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: {{ .volume.reclaimPolicy }}
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: radondb-nfs-pv
labels:
type: local
spec:
storageClassName: radondb-nfs-hostpath
{{ if not (empty .volume.hostName)}}
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- {{ .volume.hostName }}
{{- end }}
capacity:
storage: {{ .volume.localPVCapacity }}
accessModes:
- ReadWriteOnce
hostPath:
path: "{{ .volume.hostPath }}"
{{- end }}
---
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: "{{ .nfsServerImage }}"
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:
{{- if not (empty .volume.specifiedPVC) }}
claimName: {{ .volume.specifiedPVC }}
{{- else }}
claimName: radondb-nfs-pvc
{{- end }}
---
kind: Service
apiVersion: v1
metadata:
name: radondb-nfs-server
spec:
ports:
- name: nfs
port: 2049
- name: mountd
port: 20048
- name: rpcbind
port: 111
selector:
role: nfs-server
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/mysql-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ serviceMonitor:
app.kubernetes.io/managed-by: mysql.radondb.com
app.kubernetes.io/name: mysql

nfsBackup:
installServer: false
nfsServerImage: gcr.azk8s.cn/google_containers/volume-nfs:0.8

## You can specify a pvc which you created by yourself or use local pv created by chart.
volume:
# specifiedPVC: ""

## If true, chart will create:
## 1. storage class named `radondb-nfs-local`.
## 2. a pvc which size is `localPVCapacity`.
## 3. a pv which source is `hostPath`.
createLocalPV: false
## PV will be deleted when delete release using `helm delete`, use Retain can hold data in the host.
reclaimPolicy: Retain
localPVCapacity: 50G
hostName: ""
hostPath: "/mnt/radondb-nfs-backup"