Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.

Commit 85c5ffc

Browse files
authored
Fix gcp mysql deployment file (#135)
1 parent 4dbd925 commit 85c5ffc

20 files changed

+1084
-3
lines changed
-9.31 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
OWNERS
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
name: mysql
3+
version: 1.6.2
4+
appVersion: 5.7.28
5+
description: Fast, reliable, scalable, and easy to use open-source relational database
6+
system.
7+
keywords:
8+
- mysql
9+
- database
10+
- sql
11+
home: https://www.mysql.com/
12+
icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png
13+
sources:
14+
- https://github.com/kubernetes/charts
15+
- https://github.com/docker-library/mysql
16+
maintainers:
17+
- name: olemarkus
18+
19+
- name: viglesiasce
20+
21+
engine: gotpl
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvers:
2+
- olemarkus
3+
reviewers:
4+
- olemarkus

addons/gcp-service-broker-0.1.0/chart/gcp-service-broker/charts/mysql/README.md

Lines changed: 241 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
MySQL can be accessed via port 3306 on the following DNS name from within your cluster:
2+
{{ template "mysql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
3+
4+
{{- if .Values.existingSecret }}
5+
If you have not already created the mysql password secret:
6+
7+
kubectl create secret generic {{ .Values.existingSecret }} --namespace {{ .Release.Namespace }} --from-file=./mysql-root-password --from-file=./mysql-password
8+
{{ else }}
9+
10+
To get your root password run:
11+
12+
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)
13+
{{- end }}
14+
15+
To connect to your database:
16+
17+
1. Run an Ubuntu pod that you can use as a client:
18+
19+
kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il
20+
21+
2. Install the mysql client:
22+
23+
$ apt-get update && apt-get install mysql-client -y
24+
25+
3. Connect using the mysql cli, then provide your password:
26+
$ mysql -h {{ template "mysql.fullname" . }} -p
27+
28+
To connect to your database directly from outside the K8s cluster:
29+
{{- if contains "NodePort" .Values.service.type }}
30+
MYSQL_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}')
31+
MYSQL_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath='{.spec.ports[0].nodePort}')
32+
33+
{{- else if contains "ClusterIP" .Values.service.type }}
34+
MYSQL_HOST=127.0.0.1
35+
MYSQL_PORT={{ .Values.service.port }}
36+
37+
# Execute the following command to route the connection:
38+
kubectl port-forward svc/{{ template "mysql.fullname" . }} {{ .Values.service.port }}
39+
40+
{{- end }}
41+
42+
mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}
43+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "mysql.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "mysql.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- printf .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Generate chart secret name
29+
*/}}
30+
{{- define "mysql.secretName" -}}
31+
{{ default (include "mysql.fullname" .) .Values.existingSecret }}
32+
{{- end -}}
33+
34+
{{/*
35+
Create the name of the service account to use
36+
*/}}
37+
{{- define "mysql.serviceAccountName" -}}
38+
{{- if .Values.serviceAccount.create -}}
39+
{{ default (include "mysql.fullname" .) .Values.serviceAccount.name }}
40+
{{- else -}}
41+
{{ default "default" .Values.serviceAccount.name }}
42+
{{- end -}}
43+
{{- end -}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.configurationFiles }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "mysql.fullname" . }}-configuration
6+
namespace: {{ .Release.Namespace }}
7+
data:
8+
{{- range $key, $val := .Values.configurationFiles }}
9+
{{ $key }}: |-
10+
{{ $val | indent 4}}
11+
{{- end }}
12+
{{- end -}}
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "mysql.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
app: {{ template "mysql.fullname" . }}
8+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
{{- with .Values.deploymentAnnotations }}
12+
annotations:
13+
{{ toYaml . | indent 4 }}
14+
{{- end }}
15+
16+
spec:
17+
strategy:
18+
{{ toYaml .Values.strategy | indent 4 }}
19+
selector:
20+
matchLabels:
21+
app: {{ template "mysql.fullname" . }}
22+
release: {{ .Release.Name }}
23+
template:
24+
metadata:
25+
labels:
26+
app: {{ template "mysql.fullname" . }}
27+
release: {{ .Release.Name }}
28+
{{- with .Values.podLabels }}
29+
{{ toYaml . | indent 8 }}
30+
{{- end }}
31+
{{- with .Values.podAnnotations }}
32+
annotations:
33+
{{ toYaml . | indent 8 }}
34+
{{- end }}
35+
spec:
36+
{{- if .Values.schedulerName }}
37+
schedulerName: "{{ .Values.schedulerName }}"
38+
{{- end }}
39+
{{- if .Values.imagePullSecrets }}
40+
imagePullSecrets:
41+
{{ toYaml .Values.imagePullSecrets | indent 8 }}
42+
{{- end }}
43+
{{- if .Values.priorityClassName }}
44+
priorityClassName: "{{ .Values.priorityClassName }}"
45+
{{- end }}
46+
{{- if .Values.securityContext.enabled }}
47+
securityContext:
48+
fsGroup: {{ .Values.securityContext.fsGroup }}
49+
runAsUser: {{ .Values.securityContext.runAsUser }}
50+
{{- end }}
51+
serviceAccountName: {{ template "mysql.serviceAccountName" . }}
52+
initContainers:
53+
- name: "remove-lost-found"
54+
image: "{{ .Values.busybox.image}}:{{ .Values.busybox.tag }}"
55+
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
56+
resources:
57+
{{ toYaml .Values.initContainer.resources | indent 10 }}
58+
command: ["rm", "-fr", "/var/lib/mysql/lost+found"]
59+
volumeMounts:
60+
- name: data
61+
mountPath: /var/lib/mysql
62+
{{- if .Values.persistence.subPath }}
63+
subPath: {{ .Values.persistence.subPath }}
64+
{{- end }}
65+
{{- if .Values.extraInitContainers }}
66+
{{ tpl .Values.extraInitContainers . | indent 6 }}
67+
{{- end }}
68+
{{- if .Values.nodeSelector }}
69+
nodeSelector:
70+
{{ toYaml .Values.nodeSelector | indent 8 }}
71+
{{- end }}
72+
{{- if .Values.tolerations }}
73+
tolerations:
74+
{{ toYaml .Values.tolerations | indent 8 }}
75+
{{- end }}
76+
containers:
77+
- name: {{ template "mysql.fullname" . }}
78+
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
79+
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
80+
81+
{{- with .Values.args }}
82+
args:
83+
{{- range . }}
84+
- {{ . | quote }}
85+
{{- end }}
86+
{{- end }}
87+
resources:
88+
{{ toYaml .Values.resources | indent 10 }}
89+
env:
90+
{{- if .Values.mysqlAllowEmptyPassword }}
91+
- name: MYSQL_ALLOW_EMPTY_PASSWORD
92+
value: "true"
93+
{{- end }}
94+
{{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqlRootPassword)) }}
95+
- name: MYSQL_ROOT_PASSWORD
96+
valueFrom:
97+
secretKeyRef:
98+
name: {{ template "mysql.secretName" . }}
99+
key: mysql-root-password
100+
{{- if .Values.mysqlAllowEmptyPassword }}
101+
optional: true
102+
{{- end }}
103+
{{- end }}
104+
{{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqPassword)) }}
105+
- name: MYSQL_PASSWORD
106+
valueFrom:
107+
secretKeyRef:
108+
name: {{ template "mysql.secretName" . }}
109+
key: mysql-password
110+
{{- if or .Values.mysqlAllowEmptyPassword (empty .Values.mysqlUser) }}
111+
optional: true
112+
{{- end }}
113+
{{- end }}
114+
- name: MYSQL_USER
115+
value: {{ default "" .Values.mysqlUser | quote }}
116+
- name: MYSQL_DATABASE
117+
value: {{ default "" .Values.mysqlDatabase | quote }}
118+
{{- if .Values.timezone }}
119+
- name: TZ
120+
value: {{ .Values.timezone }}
121+
{{- end }}
122+
ports:
123+
- name: mysql
124+
containerPort: 3306
125+
livenessProbe:
126+
exec:
127+
command:
128+
{{- if .Values.mysqlAllowEmptyPassword }}
129+
- mysqladmin
130+
- ping
131+
{{- else }}
132+
- sh
133+
- -c
134+
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
135+
{{- end }}
136+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
137+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
138+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
139+
successThreshold: {{ .Values.livenessProbe.successThreshold }}
140+
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
141+
readinessProbe:
142+
exec:
143+
command:
144+
{{- if .Values.mysqlAllowEmptyPassword }}
145+
- mysqladmin
146+
- ping
147+
{{- else }}
148+
- sh
149+
- -c
150+
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
151+
{{- end }}
152+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
153+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
154+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
155+
successThreshold: {{ .Values.readinessProbe.successThreshold }}
156+
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
157+
volumeMounts:
158+
- name: data
159+
mountPath: /var/lib/mysql
160+
{{- if .Values.persistence.subPath }}
161+
subPath: {{ .Values.persistence.subPath }}
162+
{{- end }}
163+
{{- if .Values.configurationFiles }}
164+
{{- range $key, $val := .Values.configurationFiles }}
165+
- name: configurations
166+
mountPath: {{ $.Values.configurationFilesPath }}{{ $key }}
167+
subPath: {{ $key }}
168+
{{- end -}}
169+
{{- end }}
170+
{{- if .Values.initializationFiles }}
171+
- name: migrations
172+
mountPath: /docker-entrypoint-initdb.d
173+
{{- end }}
174+
{{- if .Values.ssl.enabled }}
175+
- name: certificates
176+
mountPath: /ssl
177+
{{- end }}
178+
{{- if .Values.extraVolumeMounts }}
179+
{{ tpl .Values.extraVolumeMounts . | indent 8 }}
180+
{{- end }}
181+
{{- if .Values.metrics.enabled }}
182+
- name: metrics
183+
image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}"
184+
imagePullPolicy: {{ .Values.metrics.imagePullPolicy | quote }}
185+
{{- if .Values.mysqlAllowEmptyPassword }}
186+
command:
187+
- 'sh'
188+
- '-c'
189+
- 'DATA_SOURCE_NAME="root@(localhost:3306)/" /bin/mysqld_exporter'
190+
{{- else }}
191+
env:
192+
- name: MYSQL_ROOT_PASSWORD
193+
valueFrom:
194+
secretKeyRef:
195+
name: {{ template "mysql.secretName" . }}
196+
key: mysql-root-password
197+
command:
198+
- 'sh'
199+
- '-c'
200+
- 'DATA_SOURCE_NAME="root:$MYSQL_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter'
201+
{{- end }}
202+
{{- range $f := .Values.metrics.flags }}
203+
- {{ $f | quote }}
204+
{{- end }}
205+
ports:
206+
- name: metrics
207+
containerPort: 9104
208+
livenessProbe:
209+
httpGet:
210+
path: /
211+
port: metrics
212+
initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
213+
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
214+
readinessProbe:
215+
httpGet:
216+
path: /
217+
port: metrics
218+
initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
219+
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
220+
resources:
221+
{{ toYaml .Values.metrics.resources | indent 10 }}
222+
{{- end }}
223+
volumes:
224+
{{- if .Values.configurationFiles }}
225+
- name: configurations
226+
configMap:
227+
name: {{ template "mysql.fullname" . }}-configuration
228+
{{- end }}
229+
{{- if .Values.initializationFiles }}
230+
- name: migrations
231+
configMap:
232+
name: {{ template "mysql.fullname" . }}-initialization
233+
{{- end }}
234+
{{- if .Values.ssl.enabled }}
235+
- name: certificates
236+
secret:
237+
secretName: {{ .Values.ssl.secret }}
238+
{{- end }}
239+
- name: data
240+
{{- if .Values.persistence.enabled }}
241+
persistentVolumeClaim:
242+
claimName: {{ .Values.persistence.existingClaim | default (include "mysql.fullname" .) }}
243+
{{- else }}
244+
emptyDir: {}
245+
{{- end -}}
246+
{{- if .Values.extraVolumes }}
247+
{{ tpl .Values.extraVolumes . | indent 6 }}
248+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.initializationFiles }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "mysql.fullname" . }}-initialization
6+
namespace: {{ .Release.Namespace }}
7+
data:
8+
{{- range $key, $val := .Values.initializationFiles }}
9+
{{ $key }}: |-
10+
{{ $val | indent 4}}
11+
{{- end }}
12+
{{- end -}}

0 commit comments

Comments
 (0)