-
Notifications
You must be signed in to change notification settings - Fork 129
/
local-cr.yaml
133 lines (133 loc) · 2.93 KB
/
local-cr.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
apiVersion: v1
kind: Namespace
metadata:
name: mariadb-db
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mariadb-custom-config
namespace: mariadb-db
data:
custom.conf: |
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
port=3306
ssl=0
[mysqld]
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_adaptive_flushing=1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mariadb-deployment
namespace: mariadb-db
spec:
selector:
matchLabels:
app: mariadb
template:
metadata:
labels:
app: mariadb
type: mariadb-database-server
spec:
nodeSelector:
kubernetes.io/hostname: "master-0"
terminationGracePeriodSeconds: 10
containers:
- name: mariadb
image: centos/mariadb-103-centos8:latest
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 3306
resources:
requests:
cpu: 200m
memory: 100Mi
limits:
cpu: 4
memory: 16Gi
env:
- name: MYSQL_USER
value: "test"
- name: MYSQL_PASSWORD
value: "test"
- name: MYSQL_ROOT_PASSWORD
value: "mysql"
securityContext:
privileged: true
volumeMounts:
- name: mariadb-custom-config
mountPath: /etc/my.cnf
subPath: custom.conf #should be the name used in the ConfigMap
- name: maria-persistent-storage
mountPath: /var/lib/mysql
readOnly: false
volumes:
- name: mariadb-custom-config
configMap:
name: mariadb-custom-config
- name: maria-persistent-storage
persistentVolumeClaim:
claimName: maria-persistent-storage
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pvdb
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: localblock
local:
# mkdir inside node
path: /var/lib/mysql
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- master-0
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: maria-persistent-storage
namespace: mariadb-db
spec:
storageClassName: localblock
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
name: mariadb-deployment
namespace: mariadb-db
spec:
selector:
app: mariadb
ports:
- protocol: TCP
port: 3306
targetPort: 3306
---