Skip to content

Commit 4000af5

Browse files
committed
feat(drycc-addons):add mysql-cluster
1 parent f5a8cdd commit 4000af5

29 files changed

Lines changed: 1081 additions & 1400 deletions

addons/minio/2023/chart/minio/.helmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
.project
2020
.idea/
2121
*.tmproj
22+
.vscode/

addons/mysql-cluster/8.0/chart/mysql-cluster/Chart.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ apiVersion: v2
44
appVersion: 8.0.30
55
dependencies:
66
- name: common
7-
repository: https://charts.bitnami.com/bitnami
7+
repository: oci://registry.drycc.cc/charts
88
tags:
9-
- bitnami-common
10-
version: 2.x.x
9+
- drycc-common
10+
version: ~1.1.2
1111
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.
1212
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
13+
home: https://github.com/drycc/charts/tree/master/drycc/mysql
14+
icon: https://drycc.com/assets/stacks/mysql/img/mysql-stack-220x234.png
1515
keywords:
1616
- mysql
1717
- database
1818
- sql
1919
- cluster
2020
- high availability
2121
maintainers:
22-
- name: Bitnami
23-
url: https://github.com/bitnami/charts
22+
- name: Drycc
23+
url: https://github.com/drycc/charts
2424
name: mysql
2525
sources:
26-
- https://github.com/bitnami/containers/tree/main/bitnami/mysql
26+
- https://github.com/drycc/containers/tree/main/drycc/mysql
2727
- https://mysql.com
2828
version: 9.3.5

addons/mysql-cluster/8.0/chart/mysql-cluster/handler.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

addons/mysql-cluster/8.0/chart/mysql-cluster/int-mysql.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

addons/mysql-cluster/8.0/chart/mysql-cluster/mysql.conf

Lines changed: 0 additions & 62 deletions
This file was deleted.

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/_helpers.tpl

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{/*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{/* vim: set filetype=mustache: */}}
27

38
{{- define "mysql.primary.fullname" -}}
@@ -8,8 +13,13 @@
813
{{- end -}}
914
{{- end -}}
1015

11-
{{- define "mysql.secondary.fullname" -}}
12-
{{- printf "%s-%s" (include "common.names.fullname" .) .Values.secondary.name | trunc 63 | trimSuffix "-" -}}
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 "-" -}}
1323
{{- end -}}
1424

1525
{{/*
@@ -19,6 +29,20 @@ Return the proper MySQL image name
1929
{{- include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
2030
{{- end -}}
2131

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+
2246
{{/*
2347
Return the proper metrics image name
2448
*/}}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{{- /*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
apiVersion: {{ include "common.capabilities.cronjob.apiVersion" . }}
7+
kind: Job
8+
metadata:
9+
name: {{ include "mysql.cluster.fullname" . }}
10+
namespace: {{ include "common.names.namespace" . | quote }}
11+
labels: {{- include "common.labels.standard" . | nindent 4 }}
12+
app.kubernetes.io/component: primary
13+
{{- if .Values.commonLabels }}
14+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
15+
{{- end }}
16+
{{- if .Values.commonAnnotations }}
17+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
18+
{{- end }}
19+
20+
spec:
21+
template:
22+
spec:
23+
restartPolicy: Never
24+
initContainers:
25+
- name: init-wait
26+
image: registry.uucin.com/drycc/python-dev:latest
27+
imagePullPolicy: {{.Values.imagePullPolicy}}
28+
args:
29+
- netcat
30+
- -v
31+
- -u
32+
- mysql://$(MYSQL_MASTER_HOST)-0.$(MYSQL_MASTER_HOST):$(MYSQL_MASTER_PORT_NUMBER),mysql://$(MYSQL_MASTER_HOST)-1.$(MYSQL_MASTER_HOST):$(MYSQL_MASTER_PORT_NUMBER),mysql://$(MYSQL_MASTER_HOST)-2.$(MYSQL_MASTER_HOST):$(MYSQL_MASTER_PORT_NUMBER)
33+
34+
env:
35+
- name: MYSQL_MASTER_HOST
36+
value: {{ include "mysql.primary.fullname" . }}
37+
- name: MYSQL_MASTER_PORT_NUMBER
38+
value: {{ .Values.primary.service.ports.mysql | quote }}
39+
40+
- name: mgr
41+
image: {{ include "mysql.image" . }}
42+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
43+
{{- if .Values.primary.containerSecurityContext.enabled }}
44+
securityContext: {{- omit .Values.primary.containerSecurityContext "enabled" | toYaml | nindent 12 }}
45+
{{- end }}
46+
command:
47+
- /bin/bash
48+
- -ec
49+
- |
50+
export HOST_0=${MYSQL_MASTER_HOST}-0.${MYSQL_MASTER_HOST}
51+
export HOST_1=${MYSQL_MASTER_HOST}-1.${MYSQL_MASTER_HOST}
52+
export HOST_2=${MYSQL_MASTER_HOST}-2.${MYSQL_MASTER_HOST}
53+
54+
echo "
55+
set global group_replication_bootstrap_group=on;
56+
start group_replication;
57+
select * from performance_schema.replication_group_members;
58+
set global group_replication_bootstrap_group=off;
59+
" > /tmp/master.sql
60+
mysql -h${HOST_0} -P${MYSQL_MASTER_PORT_NUMBER} -uroot -p${MYSQL_ROOT_PASSWORD} < /tmp/master.sql
61+
62+
echo "
63+
reset master;
64+
change master to master_user='$(MYSQL_REPLICATION_USER)',master_password='$(MYSQL_REPLICATION_PASSWORD)' for channel 'group_replication_recovery';
65+
start group_replication;
66+
select * from performance_schema.replication_group_members;
67+
" > /tmp/slave.sql
68+
mysql -h${HOST_1} -P${MYSQL_MASTER_PORT_NUMBER} -uroot -p${MYSQL_ROOT_PASSWORD} < /tmp/slave.sql
69+
mysql -h${HOST_2} -P${MYSQL_MASTER_PORT_NUMBER} -uroot -p${MYSQL_ROOT_PASSWORD} < /tmp/slave.sql
70+
71+
env:
72+
- name: DRYCC_DEBUG
73+
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
74+
- name: MYSQL_MASTER_HOST
75+
value: {{ include "mysql.primary.fullname" . }}
76+
- name: MYSQL_MASTER_PORT_NUMBER
77+
value: {{ .Values.primary.service.ports.mysql | quote }}
78+
- name: MYSQL_MASTER_ROOT_USER
79+
value: "root"
80+
- name: MYSQL_ROOT_PASSWORD
81+
valueFrom:
82+
secretKeyRef:
83+
name: {{ template "mysql.secretName" . }}
84+
key: mysql-root-password
85+
- name: MYSQL_REPLICATION_USER
86+
value: {{ .Values.auth.replicationUser | quote }}
87+
- name: MYSQL_REPLICATION_PASSWORD
88+
valueFrom:
89+
secretKeyRef:
90+
name: {{ template "mysql.secretName" . }}
91+
key: mysql-replication-password
92+
93+
containers:
94+
- name: cluster
95+
image: {{ include "cluster.image" . }}
96+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
97+
{{- if .Values.primary.containerSecurityContext.enabled }}
98+
securityContext: {{- omit .Values.primary.containerSecurityContext "enabled" | toYaml | nindent 12 }}
99+
{{- end }}
100+
command:
101+
- /bin/bash
102+
- -ec
103+
- |
104+
export HOST_0=${MYSQL_MASTER_HOST}-0.${MYSQL_MASTER_HOST}
105+
echo 'Y' | mysqlsh --uri=${MYSQL_MASTER_ROOT_USER}@${HOST_0}:${MYSQL_MASTER_PORT_NUMBER} -p${MYSQL_ROOT_PASSWORD} -e'var c=dba.createCluster("MXMGR");'
106+
107+
env:
108+
- name: MYSQL_MASTER_HOST
109+
value: {{ include "mysql.primary.fullname" . }}
110+
- name: MYSQL_MASTER_PORT_NUMBER
111+
value: {{ .Values.primary.service.ports.mysql | quote }}
112+
- name: MYSQL_MASTER_ROOT_USER
113+
value: "root"
114+
- name: MYSQL_ROOT_PASSWORD
115+
valueFrom:
116+
secretKeyRef:
117+
name: {{ template "mysql.secretName" . }}
118+
key: mysql-root-password

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/extra-list.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{- /*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- range .Values.extraDeploy }}
27
---
38
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/metrics-svc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{- /*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if .Values.metrics.enabled }}
27
apiVersion: v1
38
kind: Service
@@ -20,6 +25,9 @@ metadata:
2025
{{- end }}
2126
spec:
2227
type: {{ .Values.metrics.service.type }}
28+
{{- if and .Values.metrics.service.clusterIP (eq .Values.metrics.service.type "ClusterIP") }}
29+
clusterIP: {{ .Values.metrics.service.clusterIP }}
30+
{{- end }}
2331
ports:
2432
- port: {{ .Values.metrics.service.port }}
2533
targetPort: metrics

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/networkpolicy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{- /*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if .Values.networkPolicy.enabled }}
27
kind: NetworkPolicy
38
apiVersion: {{ template "common.capabilities.networkPolicy.apiVersion" . }}

0 commit comments

Comments
 (0)