Skip to content

Commit 90b3a8b

Browse files
authored
Merge pull request #455 from runkecheng/feature_chart_support_nfs
chart: support NFS backup.
2 parents 8b28e45 + daecee1 commit 90b3a8b

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{{- with .Values.nfsBackup -}}
2+
## installServer & (specifiedPVC | createLocalPV)
3+
{{- if (and .installServer (or (not (empty .volume.specifiedPVC)) .volume.createLocalPV )) -}}
4+
{{- if (and (empty .volume.specifiedPVC) .volume.createLocalPV) }}
5+
apiVersion: v1
6+
kind: PersistentVolumeClaim
7+
metadata:
8+
name: radondb-nfs-pvc
9+
spec:
10+
storageClassName: radondb-nfs-hostpath
11+
accessModes:
12+
- ReadWriteOnce
13+
resources:
14+
requests:
15+
storage: {{ .volume.localPVCapacity }}
16+
---
17+
apiVersion: storage.k8s.io/v1
18+
kind: StorageClass
19+
metadata:
20+
annotations:
21+
name: radondb-nfs-hostpath
22+
provisioner: kubernetes.io/no-provisioner
23+
reclaimPolicy: {{ .volume.reclaimPolicy }}
24+
volumeBindingMode: WaitForFirstConsumer
25+
---
26+
apiVersion: v1
27+
kind: PersistentVolume
28+
metadata:
29+
name: radondb-nfs-pv
30+
labels:
31+
type: local
32+
spec:
33+
storageClassName: radondb-nfs-hostpath
34+
{{ if not (empty .volume.hostName)}}
35+
nodeAffinity:
36+
required:
37+
nodeSelectorTerms:
38+
- matchExpressions:
39+
- key: kubernetes.io/hostname
40+
operator: In
41+
values:
42+
- {{ .volume.hostName }}
43+
{{- end }}
44+
capacity:
45+
storage: {{ .volume.localPVCapacity }}
46+
accessModes:
47+
- ReadWriteOnce
48+
hostPath:
49+
path: "{{ .volume.hostPath }}"
50+
{{- end }}
51+
---
52+
apiVersion: v1
53+
kind: ReplicationController
54+
metadata:
55+
name: radondb-nfs-server
56+
spec:
57+
replicas: 1
58+
selector:
59+
role: nfs-server
60+
template:
61+
metadata:
62+
labels:
63+
role: nfs-server
64+
spec:
65+
containers:
66+
- name: nfs-server
67+
## TODO: radondb/volume-nfs:0.8
68+
image: "{{ .nfsServerImage }}"
69+
ports:
70+
- name: nfs
71+
containerPort: 2049
72+
- name: mountd
73+
containerPort: 20048
74+
- name: rpcbind
75+
containerPort: 111
76+
securityContext:
77+
privileged: true
78+
volumeMounts:
79+
- mountPath: /exports
80+
name: nfs-export-fast
81+
volumes:
82+
- name: nfs-export-fast
83+
persistentVolumeClaim:
84+
{{- if not (empty .volume.specifiedPVC) }}
85+
claimName: {{ .volume.specifiedPVC }}
86+
{{- else }}
87+
claimName: radondb-nfs-pvc
88+
{{- end }}
89+
---
90+
kind: Service
91+
apiVersion: v1
92+
metadata:
93+
name: radondb-nfs-server
94+
spec:
95+
ports:
96+
- name: nfs
97+
port: 2049
98+
- name: mountd
99+
port: 20048
100+
- name: rpcbind
101+
port: 111
102+
selector:
103+
role: nfs-server
104+
{{- end }}
105+
{{- end }}

charts/mysql-operator/values.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,21 @@ serviceMonitor:
6868
app.kubernetes.io/managed-by: mysql.radondb.com
6969
app.kubernetes.io/name: mysql
7070

71+
nfsBackup:
72+
installServer: false
73+
nfsServerImage: gcr.azk8s.cn/google_containers/volume-nfs:0.8
74+
75+
## You can specify a pvc which you created by yourself or use local pv created by chart.
76+
volume:
77+
# specifiedPVC: ""
78+
79+
## If true, chart will create:
80+
## 1. storage class named `radondb-nfs-local`.
81+
## 2. a pvc which size is `localPVCapacity`.
82+
## 3. a pv which source is `hostPath`.
83+
createLocalPV: false
84+
## PV will be deleted when delete release using `helm delete`, use Retain can hold data in the host.
85+
reclaimPolicy: Retain
86+
localPVCapacity: 50G
87+
hostName: ""
88+
hostPath: "/mnt/radondb-nfs-backup"

0 commit comments

Comments
 (0)