diff --git a/addons/mysql/scripts/init-mysql-instance-for-orc.sh b/addons/mysql/scripts/init-mysql-instance-for-orc.sh index e9ffed6e4..f7415ed86 100644 --- a/addons/mysql/scripts/init-mysql-instance-for-orc.sh +++ b/addons/mysql/scripts/init-mysql-instance-for-orc.sh @@ -108,7 +108,7 @@ setup_master_slave() { master_from_orc="" get_master_from_orc - self_last_digit=${SYNCER_POD_NAME##*-} + self_last_digit=${POD_NAME##*-} self_service_name=$(echo "${COMPONENT_NAME}_MYSQL_${self_last_digit}" | tr '_' '-' | tr '[:upper:]' '[:lower:]' ) # If the cluster is already registered to the Orchestrator and the Master of the cluster is itself, then no action is required. diff --git a/addons/mysql/scripts/mysql-entrypoint.sh b/addons/mysql/scripts/mysql-entrypoint.sh index d68c7fef4..e70edbf5b 100644 --- a/addons/mysql/scripts/mysql-entrypoint.sh +++ b/addons/mysql/scripts/mysql-entrypoint.sh @@ -1,20 +1,20 @@ #!/bin/bash -REPORT_HOST=${COMPONENT_NAME}-mysql-${SYNCER_POD_NAME##*-} -SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1)) +REPORT_HOST=${COMPONENT_NAME}-mysql-${POD_NAME##*-} +SERVICE_ID=$((${POD_NAME##*-} + 1)) if [ "${MYSQL_MAJOR}" = '5.7' ]; then docker-entrypoint.sh mysqld --server-id $SERVICE_ID --report-host ${REPORT_HOST} \ --ignore-db-dir=lost+found \ --plugin-load-add=rpl_semi_sync_master=semisync_master.so \ --plugin-load-add=rpl_semi_sync_slave=semisync_slave.so \ --plugin-load-add=audit_log=audit_log.so \ - --log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ --skip-slave-start=$skip_slave_start elif [ "${MYSQL_MAJOR}" = '8.0' ]; then docker-entrypoint.sh mysqld --server-id $SERVICE_ID --report-host ${REPORT_HOST} \ --plugin-load-add=rpl_semi_sync_source=semisync_source.so \ --plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \ --plugin-load-add=audit_log=audit_log.so \ - --log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ --skip-slave-start=$skip_slave_start else echo "Unsupported MySQL version" diff --git a/addons/mysql/templates/_helpers.tpl b/addons/mysql/templates/_helpers.tpl index 1e3496655..527e36f15 100644 --- a/addons/mysql/templates/_helpers.tpl +++ b/addons/mysql/templates/_helpers.tpl @@ -117,6 +117,16 @@ vars: valueFrom: clusterVarRef: namespace: Required + - name: COMPONENT_NAME + valueFrom: + componentVarRef: + optional: false + shortName: Required + - name: CLUSTER_COMPONENT_NAME + valueFrom: + componentVarRef: + optional: false + componentName: Required - name: MYSQL_ROOT_USER valueFrom: credentialVarRef: @@ -134,10 +144,7 @@ lifecycleActions: exec: container: mysql command: - - /tools/dbctl - - --config-path - - /tools/config/dbctl/components - - mysql + - /tools/syncerctl - getrole switchover: exec: @@ -168,18 +175,6 @@ roles: volumeMounts: - mountPath: /tools name: tools -- command: - - cp - - -r - - /bin/dbctl - - /config - - /tools/ - image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.dbctl.repository }}:{{ .Values.image.dbctl.tag }} - imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} - name: init-dbctl - volumeMounts: - - mountPath: /tools - name: tools {{- end }} {{- define "mysql-orc.spec.common"}} @@ -245,7 +240,7 @@ vars: valueFrom: componentVarRef: optional: false - componentName: Required + shortName: Required - name: MYSQL_ROOT_USER valueFrom: credentialVarRef: @@ -404,17 +399,17 @@ env: value: orchestrator - name: SERVICE_PORT value: "3306" - - name: SYNCER_POD_NAME + - name: POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - - name: SYNCER_POD_UID + - name: POD_UID valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.uid - - name: SYNCER_POD_IP + - name: POD_IP valueFrom: fieldRef: apiVersion: v1 @@ -448,6 +443,5 @@ volumeMounts: {{- define "mysql.spec.runtime.images" -}} init-jemalloc: {{ .Values.image.registry | default "docker.io" }}/apecloud/jemalloc:5.3.0 init-syncer: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.syncer.repository }}:{{ .Values.image.syncer.tag }} -init-dbctl: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.dbctl.repository }}:{{ .Values.image.dbctl.tag }} mysql-exporter: {{ .Values.metrics.image.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.metrics.image.repository }}:{{ default .Values.metrics.image.tag }} {{- end -}} diff --git a/addons/mysql/templates/cmpd-mysql57.yaml b/addons/mysql/templates/cmpd-mysql57.yaml index 3ec31e75f..db4a1da81 100644 --- a/addons/mysql/templates/cmpd-mysql57.yaml +++ b/addons/mysql/templates/cmpd-mysql57.yaml @@ -73,13 +73,13 @@ spec: if [ -f {{ .Values.dataMountPath }}/data/.restore_new_cluster ]; then skip_slave_start="ON" fi - SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1)) + SERVICE_ID=$((${POD_NAME##*-} + 1)) docker-entrypoint.sh mysqld --server-id $SERVICE_ID \ --ignore-db-dir=lost+found \ --plugin-load-add=rpl_semi_sync_master=semisync_master.so \ --plugin-load-add=rpl_semi_sync_slave=semisync_slave.so \ --plugin-load-add=audit_log=audit_log.so \ - --log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ --skip-slave-start=$skip_slave_start volumeMounts: - mountPath: {{ .Values.dataMountPath }} @@ -106,17 +106,22 @@ spec: value: {{ .Values.auth.rootHost | default "%" | quote }} - name: SERVICE_PORT value: "3306" - - name: SYNCER_POD_NAME + - name: POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - - name: SYNCER_POD_UID + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: POD_UID valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.uid - - name: SYNCER_POD_IP + - name: POD_IP valueFrom: fieldRef: apiVersion: v1 diff --git a/addons/mysql/templates/cmpd-mysql80.yaml b/addons/mysql/templates/cmpd-mysql80.yaml index f30337473..754cfb2b0 100644 --- a/addons/mysql/templates/cmpd-mysql80.yaml +++ b/addons/mysql/templates/cmpd-mysql80.yaml @@ -73,12 +73,12 @@ spec: if [ -f {{ .Values.dataMountPath }}/data/.restore_new_cluster ]; then skip_slave_start="ON" fi - SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1)) + SERVICE_ID=$((${POD_NAME##*-} + 1)) docker-entrypoint.sh mysqld --server-id $SERVICE_ID \ --plugin-load-add=rpl_semi_sync_source=semisync_source.so \ --plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \ --plugin-load-add=audit_log=audit_log.so \ - --log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ --skip-slave-start=$skip_slave_start volumeMounts: - mountPath: {{ .Values.dataMountPath }} @@ -105,17 +105,22 @@ spec: value: {{ .Values.auth.rootHost | default "%" | quote }} - name: SERVICE_PORT value: "3306" - - name: SYNCER_POD_NAME + - name: POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - - name: SYNCER_POD_UID + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: POD_UID valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.uid - - name: SYNCER_POD_IP + - name: POD_IP valueFrom: fieldRef: apiVersion: v1 diff --git a/addons/mysql/templates/cmpd-mysql84.yaml b/addons/mysql/templates/cmpd-mysql84.yaml index 5e970dcba..2a378b2e9 100644 --- a/addons/mysql/templates/cmpd-mysql84.yaml +++ b/addons/mysql/templates/cmpd-mysql84.yaml @@ -61,11 +61,11 @@ spec: if [ -f {{ .Values.dataMountPath }}/data/.restore_new_cluster ]; then skip_slave_start="ON" fi - SERVICE_ID=$((${SYNCER_POD_NAME##*-} + 1)) + SERVICE_ID=$((${POD_NAME##*-} + 1)) docker-entrypoint.sh mysqld --server-id $SERVICE_ID \ --plugin-load-add=rpl_semi_sync_source=semisync_source.so \ --plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \ - --log-bin=/var/lib/mysql/binlog/${SYNCER_POD_NAME}-bin \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ --skip-slave-start=$skip_slave_start volumeMounts: - mountPath: {{ .Values.dataMountPath }} @@ -92,17 +92,22 @@ spec: value: {{ .Values.auth.rootHost | default "%" | quote }} - name: SERVICE_PORT value: "3306" - - name: SYNCER_POD_NAME + - name: POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - - name: SYNCER_POD_UID + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: POD_UID valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.uid - - name: SYNCER_POD_IP + - name: POD_IP valueFrom: fieldRef: apiVersion: v1 diff --git a/addons/mysql/values.yaml b/addons/mysql/values.yaml index 29752141c..b9b3d7789 100644 --- a/addons/mysql/values.yaml +++ b/addons/mysql/values.yaml @@ -16,10 +16,7 @@ image: repository: apecloud/percona-xtrabackup syncer: repository: apecloud/syncer - tag: 0.3.8 - dbctl: - repository: apecloud/dbctl - tag: 0.1.5 + tag: 0.4.1 # refer: addons/mysql/orc-tools/Dockerfile orcTools: repository: apecloud/orc-tools