forked from DeekshithSN/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql-config-subpath.yaml
50 lines (50 loc) · 1.38 KB
/
mysql-config-subpath.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#https://dev.to/joshduffney/kubernetes-using-configmap-subpaths-to-mount-files-3a1i
#SubPaths are not automatically updated when a ConfigMap is modified. Changes to a ConfigMap will
#need to be a new deployment which would result in the pods being recreated with the updated ConfigMap content.
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
selector:
app: mysql
clusterIP: None
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
value: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-configmap-volume
mountPath: /etc/mysql/conf.d/binlog_format.cnf #change to impment subpath and to not replace the files in existing directory
subPath: binlog_format.cnf
volumes:
- name: mysql-configmap-volume
configMap:
name: mysql-configmap
items:
- key: mysql_binlog_format.cnf
path: binlog_format.cnf