Skip to content

Commit ff1182b

Browse files
committed
feat(drycc-addons): add mysql cluster
1 parent e3822d8 commit ff1182b

63 files changed

Lines changed: 8135 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ entries:
44
- name: mariadb
55
description: "MariaDB Server is one of the most popular open source relational databases. It’s made by the original developers of MySQL and guaranteed to stay open source. "
66
version: 1.1.0
7+
mysql-cluster:
8+
- name: mysql-cluster
9+
description: " The world's most popular open source database cluster."
10+
version: 8.0
11+
- name: mysql-cluster
12+
description: " The world's most popular open source database cluster."
13+
version: 5.7
714
minio:
815
- name: minio
916
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.30
5+
dependencies:
6+
- name: common
7+
repository: https://charts.bitnami.com/bitnami
8+
tags:
9+
- bitnami-common
10+
version: 2.x.x
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/bitnami/charts/tree/master/bitnami/mysql
14+
icon: https://bitnami.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: Bitnami
23+
url: https://github.com/bitnami/charts
24+
name: mysql
25+
sources:
26+
- https://github.com/bitnami/containers/tree/main/bitnami/mysql
27+
- https://mysql.com
28+
version: 9.3.5

addons/mysql-cluster-5.7/chart/mysql-cluster/README.md

Lines changed: 547 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
echo Primary: my-release-mysql-primary.default.svc.cluster.local:3306
2+
echo Secondary: my-release-mysql-secondary.default.svc.cluster.local:3306
3+
4+
Tip:
5+
6+
Watch the deployment status using the command: kubectl get pods -w --namespace default
7+
8+
Services:
9+
10+
echo Primary: my-release-mysql-primary.default.svc.cluster.local:3306
11+
echo Secondary: my-release-mysql-secondary.default.svc.cluster.local:3306
12+
13+
Execute the following to get the administrator credentials:
14+
15+
echo Username: root
16+
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default my-release-mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d)
17+
18+
To connect to your database:
19+
20+
1. Run a pod that you can use as a client:
21+
22+
kubectl run my-release-mysql-client --rm --tty -i --restart='Always' --image docker.io/bitnami/mysql:8.0.30-debian-11-r27 --namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash
23+
24+
2. To connect to primary service (read/write):
25+
26+
mysql -h my-release-mysql-primary.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
27+
28+
3. To connect to secondary service (read-only):
29+
30+
mysql -h my-release-mysql-secondary.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
31+
32+
mysq -uroot -p"$MYSQL_ROOT_PASSWORD"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
int-mysql.sh: |
2+
#!/bin/bash
3+
set -ex
4+
5+
# Generate mysql server-id from pod ordinal index.
6+
[[ $`hostname` =~ -([0-9]+)$ ]] || exit 1
7+
ordinal=${BASH_REMATCH[1]}
8+
echo $ordinal
9+
mgr_host=`hostname`
10+
pre_mgr_host=${mgr_host%-*}
11+
echo [mysqld] > /opt/bitnami/mysql/conf/bitnami/server-id.cnf
12+
# Add an offset to avoid reserved server-id=0 value.
13+
echo server-id=$((100 + $ordinal)) >> /opt/bitnami/mysql/conf/bitnami/server-id.cnf
14+
# Copy appropriate conf.d files from config-map to emptyDir.
15+
echo loose-group_replication_local_address=$mgr_host:24901 >> /opt/bitnami/mysql/conf/bitnami/server-id.cnf
16+
echo loose-group_replication_group_seeds= "$pre_mgr_host-0.$pre_mgr_host-1:24901,$pre_mgr_host-2.mysql:24901" >> /opt/bitnami/mysql/conf/bitnami//server-id.cnf
17+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[mysqld]
2+
# server
3+
default_authentication_plugin=mysql_native_password
4+
skip-name-resolve
5+
explicit_defaults_for_timestamp
6+
basedir=/opt/bitnami/mysql
7+
plugin_dir=/opt/bitnami/mysql/lib/plugin
8+
port=3306
9+
socket=/opt/bitnami/mysql/tmp/mysql.sock
10+
datadir=/bitnami/mysql/data
11+
tmpdir=/opt/bitnami/mysql/tmp
12+
max_allowed_packet=16M
13+
bind-address=*
14+
pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
15+
log-error=/opt/bitnami/mysql/logs/mysqld.log
16+
character-set-server=UTF8
17+
collation-server=utf8_general_ci
18+
slow_query_log=0
19+
slow_query_log_file=/opt/bitnami/mysql/logs/mysqld.log
20+
long_query_time=10.0
21+
log_timestamps=system
22+
disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"
23+
sql_require_primary_key=ON
24+
# Replication
25+
26+
log_bin=mysql-bin
27+
binlog_format=ROW
28+
gtid_mode=ON
29+
enforce_gtid_consistency=ON
30+
log_slave_updates=ON
31+
master_info_repository=TABLE
32+
relay_log_info_repository=TABLE
33+
super_read_only=ON
34+
binlog_transaction_dependency_tarcking=WRITEST
35+
transaction_write_set_extraction=XXHASH64
36+
37+
# Multi-threaded Replication
38+
slave_parallel_type=LOGICAL_CLOCK
39+
slave_preserve_commit_order=ON
40+
slave_parallel_workers=4
41+
42+
# Group Replication Settings
43+
plugin_load_add="group_replication.so"
44+
loose-group_replication_recovery_get_public_key=ON
45+
loose-group_replication_recovery_use_ssl=on
46+
loose-group_replication_group_name="80d51c50-3c11-11ee-bd0f-080027fc0450" #TODO
47+
48+
loose-group_replication_bootstrap_group=OFF
49+
loose-group_replication_start_on_boot=OFF
50+
51+
[client]
52+
port=3306
53+
socket=/opt/bitnami/mysql/tmp/mysql.sock
54+
default-character-set=UTF8
55+
plugin_dir=/opt/bitnami/mysql/lib/plugin
56+
57+
[manager]
58+
port=3306
59+
socket=/opt/bitnami/mysql/tmp/mysql.sock
60+
pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
61+
62+
!includedir /opt/bitnami/mysql
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 }}

0 commit comments

Comments
 (0)