From b406c058a01834aeee3dc74811359b3608d353ae Mon Sep 17 00:00:00 2001 From: bliubiu Date: Fri, 5 Apr 2024 12:54:27 +0800 Subject: [PATCH] add dmdb addon (#276) Signed-off-by: biaobex@163.com --- addons/dmdb/.helmignore | 23 +++++++ addons/dmdb/Chart.yaml | 25 +++++++ addons/dmdb/templates/NOTES.txt | 0 addons/dmdb/templates/_helpers.tpl | 62 ++++++++++++++++++ addons/dmdb/templates/clusterdefinition.yaml | 68 ++++++++++++++++++++ addons/dmdb/templates/clusterversion.yaml | 20 ++++++ addons/dmdb/values.yaml | 45 +++++++++++++ 7 files changed, 243 insertions(+) create mode 100644 addons/dmdb/.helmignore create mode 100644 addons/dmdb/Chart.yaml create mode 100644 addons/dmdb/templates/NOTES.txt create mode 100644 addons/dmdb/templates/_helpers.tpl create mode 100644 addons/dmdb/templates/clusterdefinition.yaml create mode 100644 addons/dmdb/templates/clusterversion.yaml create mode 100644 addons/dmdb/values.yaml diff --git a/addons/dmdb/.helmignore b/addons/dmdb/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/addons/dmdb/.helmignore @@ -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/ diff --git a/addons/dmdb/Chart.yaml b/addons/dmdb/Chart.yaml new file mode 100644 index 000000000..e1c25a6fb --- /dev/null +++ b/addons/dmdb/Chart.yaml @@ -0,0 +1,25 @@ +apiVersion: v2 +name: dmdb +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.8.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.1.0" + diff --git a/addons/dmdb/templates/NOTES.txt b/addons/dmdb/templates/NOTES.txt new file mode 100644 index 000000000..e69de29bb diff --git a/addons/dmdb/templates/_helpers.tpl b/addons/dmdb/templates/_helpers.tpl new file mode 100644 index 000000000..8546373f9 --- /dev/null +++ b/addons/dmdb/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dmdb.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "dmdb.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "dmdb.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dmdb.labels" -}} +helm.sh/chart: {{ include "dmdb.chart" . }} +{{ include "dmdb.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dmdb.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dmdb.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dmdb.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dmdb.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/addons/dmdb/templates/clusterdefinition.yaml b/addons/dmdb/templates/clusterdefinition.yaml new file mode 100644 index 000000000..0a36dddc5 --- /dev/null +++ b/addons/dmdb/templates/clusterdefinition.yaml @@ -0,0 +1,68 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ClusterDefinition +metadata: + name: dmdb + labels: + {{- include "dmdb.labels" . | nindent 4 }} +spec: + type: dmdb + connectionCredential: + username: MONITOR + password: "$(RANDOM_PASSWD)" + endpoint: "$(SVC_FQDN):$(SVC_PORT_tcp-dmdb)" + host: "$(SVC_FQDN)" + port: "$(SVC_PORT_tcp-dmdb)" + componentDefs: + - name: dmdb + workloadType: Stateful + characterType: dmdb + service: + ports: + - name: tcp-dmdb + port: 5236 + targetPort: tcp-dmdb + - name: tcp-dmap + port: 4236 + targetPort: tcp-dmap + volumeTypes: + - name: data + type: data + podSpec: + containers: + - name: dmdb + volumeMounts: + - mountPath: /opt/dmdata + name: data + imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} + ports: + - name: tcp-dmdb + containerPort: 5236 + - name: tcp-dmap + containerPort: 4236 + env: + - name: EXTENT_SIZE + value: "16" + - name: PAGE_SIZE + value: "8" + - name: LOG_SIZE + value: "256" + - name: CASE_SENSITIVE + value: "1" + - name: CHARSET + value: "0" + - name: LENGTH_IN_CHAR + value: "0" + - name: BLANK_PAD_MODE + value: "1" + - name: INSTANCE_BUFFER + value: "1000" + - name: DB_NAME + value: "DM" + - name: ARCH_SPACE_LIMIT + value: "20480" + - name: MONITOR_PWD + valueFrom: + secretKeyRef: + name: $(CONN_CREDENTIAL_SECRET_NAME) + key: password diff --git a/addons/dmdb/templates/clusterversion.yaml b/addons/dmdb/templates/clusterversion.yaml new file mode 100644 index 000000000..226ef263f --- /dev/null +++ b/addons/dmdb/templates/clusterversion.yaml @@ -0,0 +1,20 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ClusterVersion +metadata: + # major version of the component defined in values.yaml + name: dmdb-{{ .Values.image.tag }} + labels: + {{- include "dmdb.labels" . | nindent 4 }} +spec: + clusterDefinitionRef: dmdb + componentVersions: + - componentDefRef: dmdb + versionsContext: + containers: + - name: dmdb + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} + - name: exporter + image: {{ .Values.exporter.image.registry | default "docker.io" }}/{{ .Values.exporter.image.repository }}:{{ .Values.exporter.image.tag }} + imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} + diff --git a/addons/dmdb/values.yaml b/addons/dmdb/values.yaml new file mode 100644 index 000000000..f576e4f5d --- /dev/null +++ b/addons/dmdb/values.yaml @@ -0,0 +1,45 @@ +# Default values for dmdb. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + registry: biu.harbor.cn + repository: dm/dm8_single + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "0.3.0" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 5236 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# dataMountPath: /opt/dmdbms/data + +exporter: + image: + # if the value of exporter.image.registry is not specified using `--set`, it will be set to the value of 'image.registry' by default + registry: biu.harbor.cn + repository: monitor/exporter/dmdb_exporter + tag: 0.1.0 + + service: + port: 9161 +