-
Notifications
You must be signed in to change notification settings - Fork 3
/
mysql-persistent.yaml
213 lines (213 loc) · 5.44 KB
/
mysql-persistent.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
apiVersion: v1
kind: List
items:
- kind: Namespace
apiVersion: v1
metadata:
name: mysql-persistent
labels:
app: mysql
- apiVersion: v1
kind: ServiceAccount
metadata:
name: mysql-persistent-sa
namespace: mysql-persistent
labels:
component: mysql-persistent
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql
namespace: mysql-persistent
labels:
app: mysql
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- kind: SecurityContextConstraints
apiVersion: security.openshift.io/v1
metadata:
name: mysql-persistent-scc
allowPrivilegeEscalation: true
allowPrivilegedContainer: true
runAsUser:
type: RunAsAny
seLinuxContext:
type: RunAsAny
fsGroup:
type: RunAsAny
supplementalGroups:
type: RunAsAny
volumes:
- '*'
users:
- system:admin
- system:serviceaccount:mysql-persistent:mysql-persistent-sa
- apiVersion: v1
kind: Service
metadata:
annotations:
template.openshift.io/expose-uri: mariadb://{.spec.clusterIP}:{.spec.ports[?(.name=="mysql")].port}
name: mysql
namespace: mysql-persistent
labels:
app: mysql
service: mysql
spec:
ports:
- protocol: TCP
name: mysql
port: 3306
selector:
app: mysql
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
template.alpha.openshift.io/wait-for-ready: 'true'
name: mysql
namespace: mysql-persistent
labels:
e2e-app: "true"
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
e2e-app: "true"
app: mysql
curl-tool: "true"
spec:
securityContext:
runAsNonRoot: true
serviceAccountName: mysql-persistent-sa
containers:
- image: registry.redhat.io/rhel8/mariadb-105:latest
name: mysql
securityContext:
privileged: false
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
env:
- name: MYSQL_USER
value: changeme
- name: MYSQL_PASSWORD
value: changeme
- name: MYSQL_ROOT_PASSWORD
value: root
- name: MYSQL_DATABASE
value: todolist
ports:
- containerPort: 3306
name: mysql
resources:
limits:
memory: 512Mi
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
livenessProbe:
tcpSocket:
port: mysql
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
startupProbe:
exec:
command:
- /usr/bin/timeout
- 1s
- /usr/bin/mysql
- $(MYSQL_DATABASE)
- -h
- 127.0.0.1
- -u$(MYSQL_USER)
- -p$(MYSQL_PASSWORD)
- -e EXIT
initialDelaySeconds: 5
periodSeconds: 30
timeoutSeconds: 2
successThreshold: 1
failureThreshold: 40 # 40x30sec before restart pod
restartPolicy: Always
- image: docker.io/curlimages/curl:8.5.0
name: curl-tool
command: ["/bin/sleep", "infinity"]
volumes:
- name: mysql-data
persistentVolumeClaim:
claimName: mysql
- apiVersion: v1
kind: Service
metadata:
name: todolist
namespace: mysql-persistent
labels:
app: todolist
service: todolist
e2e-app: "true"
spec:
ports:
- name: web
port: 8000
targetPort: 8000
selector:
app: todolist
service: todolist
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: todolist
namespace: mysql-persistent
labels:
app: todolist
service: todolist
e2e-app: "true"
spec:
replicas: 1
selector:
app: todolist
service: todolist
strategy:
type: Recreate
template:
metadata:
labels:
app: todolist
service: todolist
e2e-app: "true"
spec:
containers:
- name: todolist
image: quay.io/rhn_engineering_whayutin/todolist-mariadb-go-2:latest
env:
- name: foo
value: bar
ports:
- containerPort: 8000
protocol: TCP
initContainers:
- name: init-myservice
image: docker.io/curlimages/curl:8.5.0
command: ['sh', '-c', 'sleep 10; until /usr/bin/nc -z -w 1 mysql 3306; do echo Trying to connect to mysql DB port; sleep 5; done; echo mysql DB port reachable']
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: todolist-route
namespace: mysql-persistent
spec:
path: "/"
to:
kind: Service
name: todolist