-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql-template.yaml
157 lines (157 loc) · 3.73 KB
/
mysql-template.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
apiVersion: v1
kind: Template
metadata:
name: mysql-template
objects:
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${APPLICATION_NAME}
name: mysql
spec:
lookupPolicy:
local: false
tags:
- from:
kind: DockerImage
name: library/mysql:5.7
importPolicy: {}
name: "latest"
referencePolicy:
type: Source
- apiVersion: v1
stringData:
database-root-password: "${DATABASE_ROOT_PASSWORD}"
kind: Secret
metadata:
name: ${APPLICATION_NAME}-secrets
type: Opaque
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: ${APPLICATION_NAME}
name: var-lib-mysql
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "${STORAGE_SIZE_IN_GB}Gi"
- apiVersion: v1
kind: DeploymentConfig
metadata:
annotations:
template.alpha.openshift.io/wait-for-ready: "true"
generation: 1
labels:
app: ${APPLICATION_NAME}
name: mysql
spec:
replicas: 1
selector:
name: mysql
strategy:
activeDeadlineSeconds: 21600
recreateParams:
timeoutSeconds: 600
resources: {}
type: Recreate
template:
metadata:
labels:
name: mysql
spec:
containers:
- env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
key: database-root-password
name: ${APPLICATION_NAME}-secrets
- name: MYSQL_DATABASE
value: "${APPLICATION_NAME}"
image: library/mysql:5.7
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 3306
timeoutSeconds: 1
name: mysql
ports:
- containerPort: 3306
protocol: TCP
readinessProbe:
exec:
command:
- /bin/sh
- -i
- -c
- MYSQL_PWD="$MYSQL_PASSWORD" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE
-e 'SELECT 1'
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
memory: 512Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/mysql
name: var-lib-mysql
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: var-lib-mysql
persistentVolumeClaim:
claimName: var-lib-mysql
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- mysql
from:
kind: ImageStreamTag
name: mysql:5.7
namespace: openshift
type: ImageChange
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
annotations:
template.openshift.io/expose-uri: mysql://{.spec.clusterIP}:{.spec.ports[?(.name=="mysql")].port}
labels:
app: ${APPLICATION_NAME}
name: mysql
spec:
ports:
- name: mysql
port: 3306
protocol: TCP
targetPort: 3306
selector:
name: mysql
sessionAffinity: None
type: ClusterIP
parameters:
- name: APPLICATION_NAME
value: mysql
- name: DATABASE_ROOT_PASSWORD
generate: expression
from: "[a-zA-Z0-9]{32}"
required: true
- name: STORAGE_SIZE_IN_GB
value: "5"