diff --git a/charts/mysql-operator/templates/nfs_backup.yaml b/charts/mysql-operator/templates/nfs_backup.yaml new file mode 100644 index 00000000..39279a06 --- /dev/null +++ b/charts/mysql-operator/templates/nfs_backup.yaml @@ -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 }} diff --git a/charts/mysql-operator/values.yaml b/charts/mysql-operator/values.yaml index 1f3f21e1..7e839111 100644 --- a/charts/mysql-operator/values.yaml +++ b/charts/mysql-operator/values.yaml @@ -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"