forked from apecloud/kubeblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create a mysql addon (apecloud#4461)
- Loading branch information
1 parent
7689c9d
commit cc7e1bc
Showing
16 changed files
with
369 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: extensions.kubeblocks.io/v1alpha1 | ||
kind: Addon | ||
metadata: | ||
name: oracle-mysql | ||
labels: | ||
{{- include "kubeblocks.labels" . | nindent 4 }} | ||
"kubeblocks.io/provider": ApeCloud | ||
{{- if .Values.keepAddons }} | ||
annotations: | ||
helm.sh/resource-policy: keep | ||
{{- end }} | ||
spec: | ||
description: 'MySQL is a widely used, open-source relational database management system (RDBMS).' | ||
|
||
type: Helm | ||
|
||
helm: | ||
{{- include "kubeblocks.addonChartLocationURL" ( dict "name" "oracle-mysql" "version" (default .Chart.Version .Values.versionOverride) "values" .Values) | indent 4 }} | ||
{{- include "kubeblocks.addonChartsImage" . | indent 4 }} | ||
|
||
installOptions: | ||
{{- if hasPrefix "oci://" .Values.addonChartLocationBase }} | ||
version: {{ default .Chart.Version .Values.versionOverride }} | ||
{{- end }} | ||
|
||
installable: | ||
autoInstall: false | ||
|
||
defaultInstallValues: | ||
- enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ | ||
*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
annotations: | ||
category: Database | ||
apiVersion: v2 | ||
name: oracle-mysql-cluster | ||
type: application | ||
version: 0.6.0-alpha.21 | ||
description: MySQL is a widely used, open-source relational database management system (RDBMS) | ||
dependencies: | ||
- name: kblib | ||
version: 0.1.0 | ||
repository: file://../kblib | ||
alias: extra | ||
|
||
# This is the version number of the MySQL being deployed. | ||
appVersion: "8.0.34" | ||
|
||
keywords: | ||
- mysql | ||
- database | ||
- sql | ||
- cluster | ||
- raft | ||
|
||
home: https://github.com/apecloud/kubeblocks/deploy/mysql-cluster | ||
icon: https://github.com/apecloud/kubeblocks/raw/main/img/logo.png | ||
|
||
maintainers: | ||
- name: ApeCloud | ||
url: https://kubeblocks.io/ | ||
|
||
sources: | ||
- https://github.com/apecloud/kubeblocks/ | ||
- https://github.com/apecloud/kubeblocks/tree/main/deploy/mysql |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: apps.kubeblocks.io/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: {{ include "kblib.clusterName" . }} | ||
labels: {{ include "kblib.clusterLabels" . | nindent 4 }} | ||
spec: | ||
clusterVersionRef: {{ .Values.version }} | ||
terminationPolicy: {{ .Values.extra.terminationPolicy }} | ||
{{- include "kblib.affinity" . | indent 2 }} | ||
clusterDefinitionRef: oracle-mysql # ref clusterdefinition.name | ||
componentSpecs: | ||
- name: mysql-comp | ||
componentDefRef: mysql-compdef # ref clusterdefinition componentDefs.name | ||
replicas: 1 | ||
serviceAccountName: {{ include "kblib.serviceAccountName" . }} | ||
{{- include "kblib.componentStorages" . | indent 6 }} | ||
{{- include "kblib.componentResources" . | indent 6 }} | ||
{{- include "kblib.componentServices" . | indent 6 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- include "kblib.rbac" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{/* | ||
Validate cpu, memory and storage | ||
*/}} | ||
{{- $cpu := (float64 .Values.cpu) }} | ||
{{- $memory := (float64 .Values.memory) }} | ||
{{- $storage := (float64 .Values.storage) }} | ||
{{- if or (lt $cpu 0.5) (gt $cpu 64.0) }} | ||
{{- fail (print "cpu must be between 0.5 and 64, got " $cpu) }} | ||
{{- end }} | ||
{{- if or (lt $memory 0.5) (gt $memory 1000.0) }} | ||
{{- fail (print "memory must be between 0.5 and 1000, got " $memory) }} | ||
{{- end }} | ||
{{- if or (lt $storage 10.0 ) (gt $storage 10000.0) }} | ||
{{- fail (print "storage must be between 10 and 1000, got " $storage) }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"title": "Version", | ||
"description": "Cluster version, run \"kbcli cv list --devel\" to see all versions.", | ||
"type": "string", | ||
"default": "oracle-mysql-8.0.34" | ||
}, | ||
"replicas": { | ||
"title": "Replicas", | ||
"description": "The number of replicas.", | ||
"type": "integer", | ||
"default": 1, | ||
"minimum": 1, | ||
"maximum": 1 | ||
}, | ||
"cpu": { | ||
"title": "CPU", | ||
"description": "CPU cores.", | ||
"type": [ | ||
"number", | ||
"string" | ||
], | ||
"default": 1, | ||
"minimum": 0.5, | ||
"maximum": 64, | ||
"multipleOf": 0.5 | ||
}, | ||
"memory": { | ||
"title": "Memory(Gi)", | ||
"description": "Memory, the unit is Gi.", | ||
"type": [ | ||
"number", | ||
"string" | ||
], | ||
"default": 1, | ||
"minimum": 0.5, | ||
"maximum": 128 | ||
}, | ||
"storage": { | ||
"title": "Storage(Gi)", | ||
"description": "Storage size, the unit is Gi.", | ||
"type": [ | ||
"number", | ||
"string" | ||
], | ||
"default": 20, | ||
"minimum": 1, | ||
"maximum": 500 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Default values for mysql-cluster. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
## @param version MySQL cluster version | ||
## | ||
version: oracle-mysql-8.0.34 | ||
## @param replicas specify cluster replicas | ||
## | ||
replicas: 1 | ||
|
||
## @param cpu | ||
## | ||
cpu: 1 | ||
|
||
## @param memory, the unit is Gi | ||
## | ||
memory: 1 | ||
## @param storage size, the unit is Gi | ||
## | ||
storage: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: v2 | ||
name: mysql | ||
description: MySQL is a widely used, open-source relational database management system (RDBMS) | ||
|
||
type: application | ||
|
||
# This is the version number of the helm chart. | ||
version: 0.6.0-alpha.21 | ||
|
||
# This is the version number of the MySQL being deployed, | ||
appVersion: "8.0.34" | ||
|
||
home: https://kubeblocks.io/ | ||
icon: https://github.com/apecloud/kubeblocks/raw/main/img/logo.png | ||
|
||
maintainers: | ||
- name: ApeCloud | ||
url: https://github.com/apecloud/kubeblocks/ | ||
|
||
|
||
sources: | ||
- https://github.com/apecloud/kubeblocks/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "oracle-mysql.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "oracle-mysql.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "oracle-mysql.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "oracle-mysql.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "oracle-mysql.labels" -}} | ||
helm.sh/chart: {{ include "oracle-mysql.chart" . }} | ||
{{ include "oracle-mysql.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: apps.kubeblocks.io/v1alpha1 | ||
kind: ClusterDefinition | ||
metadata: | ||
name: oracle-mysql | ||
labels: | ||
{{- include "oracle-mysql.labels" . | nindent 4 }} | ||
spec: | ||
connectionCredential: | ||
username: root | ||
password: "$(RANDOM_PASSWD)" | ||
endpoint: "$(SVC_FQDN):$(SVC_PORT_mysql)" | ||
host: "$(SVC_FQDN)" | ||
port: "$(SVC_PORT_mysql)" | ||
componentDefs: | ||
- name: mysql-compdef | ||
characterType: mysql | ||
workloadType: Stateful | ||
service: | ||
ports: | ||
- name: mysql | ||
port: 3306 | ||
targetPort: mysql | ||
podSpec: | ||
containers: | ||
- name: mysql-container | ||
imagePullPolicy: IfNotPresent | ||
volumeMounts: | ||
- mountPath: /var/lib/mysql | ||
name: data | ||
ports: | ||
- containerPort: 3306 | ||
name: mysql | ||
env: | ||
- name: MYSQL_ROOT_HOST | ||
value: {{ .Values.auth.rootHost | default "%" | quote }} | ||
- name: MYSQL_ROOT_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: $(CONN_CREDENTIAL_SECRET_NAME) | ||
key: username | ||
- name: MYSQL_ROOT_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: $(CONN_CREDENTIAL_SECRET_NAME) | ||
key: password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: apps.kubeblocks.io/v1alpha1 | ||
kind: ClusterVersion | ||
metadata: | ||
name: oracle-mysql-{{ default .Chart.AppVersion .Values.clusterVersionOverride }} | ||
labels: | ||
{{- include "oracle-mysql.labels" . | nindent 4 }} | ||
spec: | ||
clusterDefinitionRef: oracle-mysql | ||
componentVersions: | ||
- componentDefRef: mysql-compdef | ||
versionsContext: | ||
containers: | ||
- name: mysql-container | ||
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} | ||
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Default values for mysql. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
image: | ||
registry: docker.io | ||
repository: mysql | ||
pullPolicy: IfNotPresent | ||
tag: 8.0.34 | ||
|
||
## MySQL Authentication parameters | ||
auth: | ||
## MYSQL_ROOT_HOST | ||
rootHost: "%" | ||
## @param auth.createDatabase Whether to create the .Values.auth.database or not | ||
## | ||
createDatabase: true | ||
## @param auth.database Name for a custom database to create | ||
## MYSQL_DATABASE | ||
database: "mydb" | ||
## @param auth.username Name for a custom user to create | ||
## MYSQL_USER | ||
username: "u1" | ||
## MYSQL_PASSWORD | ||
password: "u1" | ||
## @param auth.replicationUser MySQL replication user | ||
## | ||
replicationUser: "replicator" | ||
## @param auth.replicationPassword MySQL replication user password. Ignored if existing secret is provided | ||
## | ||
replicationPassword: "" | ||
|
||
nameOverride: "" | ||
fullnameOverride: "" | ||
## MySQl ClusterVersion | ||
clusterVersionOverride: "8.0.34" |