diff --git a/deploy/apecloud-mysql-cluster/templates/cluster.yaml b/deploy/apecloud-mysql-cluster/templates/cluster.yaml index 7d777d30626..bdb476924d5 100644 --- a/deploy/apecloud-mysql-cluster/templates/cluster.yaml +++ b/deploy/apecloud-mysql-cluster/templates/cluster.yaml @@ -1,4 +1,16 @@ -{{- include "kblib.clusterCommon" . }} +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: Cluster +metadata: + name: {{ include "kblib.clusterName" . }} + labels: {{ include "kblib.clusterLabels" . | nindent 4 }} + {{- if and (eq .Values.mode "raftGroup") .Values.proxyEnabled }} + annotations: + kubeblocks.io/extra-env: '{"KB_PROXY_ENABLED":"on"}' + {{- end }} +spec: + clusterVersionRef: {{ .Values.version }} + terminationPolicy: {{ .Values.extra.terminationPolicy }} + {{- include "kblib.affinity" . | indent 2 }} clusterDefinitionRef: apecloud-mysql # ref clusterdefinition.name componentSpecs: - name: mysql diff --git a/deploy/apecloud-mysql/templates/clusterdefinition.yaml b/deploy/apecloud-mysql/templates/clusterdefinition.yaml index 1a40ac6e764..4f2422d9b40 100644 --- a/deploy/apecloud-mysql/templates/clusterdefinition.yaml +++ b/deploy/apecloud-mysql/templates/clusterdefinition.yaml @@ -199,6 +199,49 @@ spec: volumeMounts: - name: agamotto-configuration mountPath: /opt/agamotto + - name: vttablet + image: {{ .Values.wesqlscale.image.registry | default "docker.io" }}/{{ .Values.wesqlscale.image.repository }}:{{ .Values.wesqlscale.image.tag }} + imagePullPolicy: {{ default .Values.wesqlscale.image.pullPolicy "IfNotPresent" }} + ports: + - containerPort: 15100 + name: vttabletport + - containerPort: 16100 + name: vttabletgrpc + - containerPort: 40000 + name: delvedebug + env: + - name: CELL + value: {{ .Values.wesqlscale.cell | default "zone1" | quote }} + - name: ETCD_SERVER + value: "$(KB_CLUSTER_NAME)-etcd-headless" + - name: ETCD_PORT + value: "2379" + - name: TOPOLOGY_FLAGS + value: "--topo_implementation etcd2 --topo_global_server_address $(ETCD_SERVER):$(ETCD_PORT) --topo_global_root /vitess/global" + - name: VTTABLET_PORT + value: "15100" + - name: VTTABLET_GRPC_PORT + value: "16100" + - name: VTCTLD_HOST + value: "$(KB_CLUSTER_NAME)-vtctld-headless" + - name: VTCTLD_WEB_PORT + value: "15000" + - name: MYSQL_ROOT_USER + valueFrom: + secretKeyRef: + name: $(CONN_CREDENTIAL_SECRET_NAME) + key: username + optional: false + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: $(CONN_CREDENTIAL_SECRET_NAME) + key: password + optional: false + command: ["/scripts/vttablet.sh"] + volumeMounts: + - name: scripts + mountPath: /scripts volumes: - name: annotations downwardAPI: diff --git a/deploy/apecloud-mysql/templates/scripts.yaml b/deploy/apecloud-mysql/templates/scripts.yaml index c0378b83b8e..1cd1218ec2d 100644 --- a/deploy/apecloud-mysql/templates/scripts.yaml +++ b/deploy/apecloud-mysql/templates/scripts.yaml @@ -147,4 +147,62 @@ data: if [ $try_times -le 0 ];then break fi - done \ No newline at end of file + done + vttablet.sh: |- + #!/bin/bash + while [ "$KB_PROXY_ENABLED" != "on" ] + do + sleep 60 + done + cell=${CELL:-'zone1'} + uid="${KB_POD_NAME##*-}" + mysql_root=${MYSQL_ROOT_USER:-'root'} + mysql_root_passwd=${MYSQL_ROOT_PASSWORD:-'123456'} + mysql_port=${MYSQL_PORT:-'3306'} + port=${VTTABLET_PORT:-'15100'} + grpc_port=${VTTABLET_GRPC_PORT:-'16100'} + vtctld_host=${VTCTLD_HOST:-'127.0.0.1'} + vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'} + printf -v alias '%s-%010d' $cell $uid + printf -v tablet_dir 'vt_%010d' $uid + tablet_hostname=$(eval echo \$KB_"$uid"_HOSTNAME) + printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid + + tablet_type=replica + topology_fags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} + + echo "starting vttablet for $alias..." + + su vitess <