Skip to content

Commit 35b949f

Browse files
authored
chore(addons): add mysql basic 8.0 (#129)
1 parent 746ec5e commit 35b949f

49 files changed

Lines changed: 3344 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

addons/index.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ entries:
1111
mysql-cluster:
1212
- version: 8.0
1313
description: "The world's most popular open source database cluster."
14+
mysql-basic:
15+
- version: 8.0
16+
description: "The world's most popular open source database."
1417
minio:
1518
- version: 2023
1619
description: "MinIO offers high-performance, S3 compatible object storage."
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
annotations:
2+
category: Database
3+
apiVersion: v2
4+
appVersion: 8.0.35
5+
dependencies:
6+
- name: common
7+
repository: oci://registry.drycc.cc/charts
8+
tags:
9+
- drycc-common
10+
version: ~1.1.2
11+
description: MySQL is a fast, reliable, scalable, and easy to use open source relational database system. Designed to handle mission-critical, heavy-load production applications.
12+
engine: gotpl
13+
home: https://github.com/drycc/charts/tree/master/drycc/mysql
14+
icon: https://drycc.com/assets/stacks/mysql/img/mysql-stack-220x234.png
15+
keywords:
16+
- mysql
17+
- database
18+
- sql
19+
- cluster
20+
- high availability
21+
maintainers:
22+
- name: Drycc
23+
url: https://github.com/drycc/charts
24+
name: mysql
25+
sources:
26+
- https://github.com/drycc/containers/tree/main/drycc/mysql
27+
- https://mysql.com
28+
version: 8.0.35
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
CHART NAME: {{ .Chart.Name }}
2+
CHART VERSION: {{ .Chart.Version }}
3+
APP VERSION: {{ .Chart.AppVersion }}
4+
5+
** Please be patient while the chart is being deployed **
6+
7+
{{- if .Values.diagnosticMode.enabled }}
8+
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
9+
10+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
11+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
12+
13+
Get the list of pods by executing:
14+
15+
kubectl get pods --namespace {{ include "common.names.namespace" . }} -l app.kubernetes.io/instance={{ .Release.Name }}
16+
17+
Access the pod you want to debug by executing
18+
19+
kubectl exec --namespace {{ include "common.names.namespace" . }} -ti <NAME OF THE POD> -- bash
20+
21+
In order to replicate the container startup scripts execute this command:
22+
23+
/opt/bitnami/scripts/mysql/entrypoint.sh /opt/bitnami/scripts/mysql/run.sh
24+
25+
{{- else }}
26+
27+
Tip:
28+
29+
Watch the deployment status using the command: kubectl get pods -w --namespace {{ include "common.names.namespace" . }}
30+
31+
Services:
32+
33+
echo Primary: {{ include "mysql.primary.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}:{{ .Values.primary.service.ports.mysql }}
34+
{{- if eq .Values.architecture "replication" }}
35+
echo Secondary: {{ include "mysql.secondary.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}:{{ .Values.secondary.service.ports.mysql }}
36+
{{- end }}
37+
38+
Execute the following to get the administrator credentials:
39+
40+
echo Username: root
41+
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace {{ include "common.names.namespace" . }} {{ template "mysql.secretName" . }} -o jsonpath="{.data.mysql-root-password}" | base64 -d)
42+
43+
To connect to your database:
44+
45+
1. Run a pod that you can use as a client:
46+
47+
kubectl run {{ include "common.names.fullname" . }}-client --rm --tty -i --restart='Never' --image {{ template "mysql.image" . }} --namespace {{ include "common.names.namespace" . }} --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash
48+
49+
2. To connect to primary service (read/write):
50+
51+
mysql -h {{ include "mysql.primary.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }} -uroot -p"$MYSQL_ROOT_PASSWORD"
52+
53+
{{- if eq .Values.architecture "replication" }}
54+
55+
3. To connect to secondary service (read-only):
56+
57+
mysql -h {{ include "mysql.secondary.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }} -uroot -p"$MYSQL_ROOT_PASSWORD"
58+
{{- end }}
59+
60+
{{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
61+
Note: Since NetworkPolicy is enabled, only pods with label {{ template "common.names.fullname" . }}-client=true" will be able to connect to MySQL.
62+
{{- end }}
63+
64+
{{- if .Values.metrics.enabled }}
65+
66+
To access the MySQL Prometheus metrics from outside the cluster execute the following commands:
67+
68+
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ printf "%s-metrics" (include "common.names.fullname" .) }} {{ .Values.metrics.service.port }}:{{ .Values.metrics.service.port }} &
69+
curl http://127.0.0.1:{{ .Values.metrics.service.port }}/metrics
70+
71+
{{- end }}
72+
73+
{{ include "mysql.validateValues" . }}
74+
{{ include "mysql.checkRollingTags" . }}
75+
{{- end }}
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
{{/*
2+
Copyright Drycc Community.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{/* vim: set filetype=mustache: */}}
7+
8+
{{- define "mysql.primary.fullname" -}}
9+
{{- if eq .Values.architecture "replication" }}
10+
{{- printf "%s-%s" (include "common.names.fullname" .) .Values.primary.name | trunc 63 | trimSuffix "-" -}}
11+
{{- else -}}
12+
{{- include "common.names.fullname" . -}}
13+
{{- end -}}
14+
{{- end -}}
15+
16+
{{- define "mysql.router.fullname" -}}
17+
{{- printf "%s-%s" (include "common.names.fullname" .) .Values.router.name | trunc 63 | trimSuffix "-" -}}
18+
{{- end -}}
19+
20+
21+
{{- define "mysql.cluster.fullname" -}}
22+
{{- printf "%s-%s" (include "common.names.fullname" .) .Values.cluster.name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
25+
{{/*
26+
Return the proper MySQL image name
27+
*/}}
28+
{{- define "mysql.image" -}}
29+
{{- include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
30+
{{- end -}}
31+
32+
{{/*
33+
Return the proper Router image name
34+
*/}}
35+
{{- define "router.image" -}}
36+
{{- include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
37+
{{- end -}}
38+
39+
{{/*
40+
Return the proper Cluster image name
41+
*/}}
42+
{{- define "cluster.image" -}}
43+
{{- include "common.images.image" (dict "imageRoot" .Values.cluster.image "global" .Values.global) }}
44+
{{- end -}}
45+
46+
{{/*
47+
Return the proper metrics image name
48+
*/}}
49+
{{- define "mysql.metrics.image" -}}
50+
{{- include "common.images.image" (dict "imageRoot" .Values.metrics.image "global" .Values.global) }}
51+
{{- end -}}
52+
53+
{{/*
54+
Return the proper image name (for the init container volume-permissions image)
55+
*/}}
56+
{{- define "mysql.volumePermissions.image" -}}
57+
{{- include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
58+
{{- end -}}
59+
60+
{{/*
61+
Return the proper Docker Image Registry Secret Names
62+
*/}}
63+
{{- define "mysql.imagePullSecrets" -}}
64+
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.metrics.image .Values.volumePermissions.image) "global" .Values.global) }}
65+
{{- end -}}
66+
67+
{{/*
68+
Get the initialization scripts ConfigMap name.
69+
*/}}
70+
{{- define "mysql.initdbScriptsCM" -}}
71+
{{- if .Values.initdbScriptsConfigMap -}}
72+
{{- printf "%s" (tpl .Values.initdbScriptsConfigMap $) -}}
73+
{{- else -}}
74+
{{- printf "%s-init-scripts" (include "mysql.primary.fullname" .) -}}
75+
{{- end -}}
76+
{{- end -}}
77+
78+
{{/*
79+
Returns the proper service account name depending if an explicit service account name is set
80+
in the values file. If the name is not set it will default to either mysql.fullname if serviceAccount.create
81+
is true or default otherwise.
82+
*/}}
83+
{{- define "mysql.serviceAccountName" -}}
84+
{{- if .Values.serviceAccount.create -}}
85+
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
86+
{{- else -}}
87+
{{ default "default" .Values.serviceAccount.name }}
88+
{{- end -}}
89+
{{- end -}}
90+
91+
{{/*
92+
Return the configmap with the MySQL Primary configuration
93+
*/}}
94+
{{- define "mysql.primary.configmapName" -}}
95+
{{- if .Values.primary.existingConfigmap -}}
96+
{{- printf "%s" (tpl .Values.primary.existingConfigmap $) -}}
97+
{{- else -}}
98+
{{- printf "%s" (include "mysql.primary.fullname" .) -}}
99+
{{- end -}}
100+
{{- end -}}
101+
102+
{{/*
103+
Return the configmap with the MySQL Router configuration
104+
*/}}
105+
{{- define "mysql.router.configmapName" -}}
106+
{{- if .Values.router.existingConfigmap -}}
107+
{{- printf "%s" (tpl .Values.router.existingConfigmap $) -}}
108+
{{- else -}}
109+
{{- printf "%s-router" (include "common.names.fullname" .) -}}
110+
{{- end -}}
111+
{{- end -}}
112+
113+
{{/*
114+
Return true if a configmap object should be created for MySQL Secondary
115+
*/}}
116+
{{- define "mysql.primary.createConfigmap" -}}
117+
{{- if and .Values.primary.configuration (not .Values.primary.existingConfigmap) }}
118+
{{- true -}}
119+
{{- else -}}
120+
{{- end -}}
121+
{{- end -}}
122+
123+
{{/*
124+
Return true if a configmap object should be created for MySQL router
125+
*/}}
126+
{{- define "mysql.router.createConfigmap" -}}
127+
{{- if and .Values.router.configuration (not .Values.router.existingConfigmap) }}
128+
{{- true -}}
129+
{{- else -}}
130+
{{- end -}}
131+
{{- end -}}
132+
133+
{{/*
134+
Return the configmap with the MySQL Primary configuration
135+
*/}}
136+
{{- define "mysql.secondary.configmapName" -}}
137+
{{- if .Values.secondary.existingConfigmap -}}
138+
{{- printf "%s" (tpl .Values.secondary.existingConfigmap $) -}}
139+
{{- else -}}
140+
{{- printf "%s" (include "mysql.secondary.fullname" .) -}}
141+
{{- end -}}
142+
{{- end -}}
143+
144+
{{/*
145+
Return true if a configmap object should be created for MySQL Secondary
146+
*/}}
147+
{{- define "mysql.secondary.createConfigmap" -}}
148+
{{- if and (eq .Values.architecture "replication") .Values.secondary.configuration (not .Values.secondary.existingConfigmap) }}
149+
{{- true -}}
150+
{{- else -}}
151+
{{- end -}}
152+
{{- end -}}
153+
154+
{{/*
155+
Return the secret with MySQL credentials
156+
*/}}
157+
{{- define "mysql.secretName" -}}
158+
{{- if .Values.auth.existingSecret -}}
159+
{{- printf "%s" (tpl .Values.auth.existingSecret $) -}}
160+
{{- else -}}
161+
{{- printf "%s" (include "common.names.fullname" .) -}}
162+
{{- end -}}
163+
{{- end -}}
164+
165+
{{/*
166+
Return true if a secret object should be created for MySQL
167+
*/}}
168+
{{- define "mysql.createSecret" -}}
169+
{{- if and (not .Values.auth.existingSecret) (not .Values.auth.customPasswordFiles) }}
170+
{{- true -}}
171+
{{- end -}}
172+
{{- end -}}
173+
174+
{{/*
175+
Returns the available value for certain key in an existing secret (if it exists),
176+
otherwise it generates a random value.
177+
*/}}
178+
{{- define "getValueFromSecret" }}
179+
{{- $len := (default 16 .Length) | int -}}
180+
{{- $obj := (lookup "v1" "Secret" .Namespace .Name).data -}}
181+
{{- if $obj }}
182+
{{- index $obj .Key | b64dec -}}
183+
{{- else -}}
184+
{{- randAlphaNum $len -}}
185+
{{- end -}}
186+
{{- end }}
187+
188+
{{/* Check if there are rolling tags in the images */}}
189+
{{- define "mysql.checkRollingTags" -}}
190+
{{- include "common.warnings.rollingTag" .Values.image }}
191+
{{- include "common.warnings.rollingTag" .Values.metrics.image }}
192+
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
193+
{{- end -}}
194+
195+
{{/*
196+
Compile all warnings into a single message, and call fail.
197+
*/}}
198+
{{- define "mysql.validateValues" -}}
199+
{{- $messages := list -}}
200+
{{- $messages := without $messages "" -}}
201+
{{- $message := join "\n" $messages -}}
202+
203+
{{- if $message -}}
204+
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
205+
{{- end -}}
206+
{{- end -}}

0 commit comments

Comments
 (0)