diff --git a/deploy/apecloud-mysql-cluster/templates/_helpers.tpl b/deploy/apecloud-mysql-cluster/templates/_helpers.tpl index 0fcf77ecbf7..e5697664fd8 100644 --- a/deploy/apecloud-mysql-cluster/templates/_helpers.tpl +++ b/deploy/apecloud-mysql-cluster/templates/_helpers.tpl @@ -15,7 +15,9 @@ The minimum proxy cpu cores is 0.5 and the maximum cpu cores is 64. - name: vtcontroller componentDefRef: vtcontroller # ref clusterdefinition componentDefs.name enabledLogs: - - log + - error + - warning + - info volumeClaimTemplates: - name: data spec: diff --git a/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config-constraint.cue b/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config-constraint.cue index fe07d78c271..337eeaf4b82 100644 --- a/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config-constraint.cue +++ b/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config-constraint.cue @@ -17,6 +17,9 @@ #VtConsensusParameter: { + // Enable or disable logs. (default true) + enable_logs: bool + // Refresh interval to load tablets. (default 10s) refresh_interval: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" diff --git a/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config.tpl b/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config.tpl index 29fe008b94a..958c4658d79 100644 --- a/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config.tpl +++ b/deploy/apecloud-mysql/config/mysql-scale-vtconsensus-config.tpl @@ -1,3 +1,9 @@ [vtconsensus] refresh_interval=1s -scan_repair_timeout=1s \ No newline at end of file +scan_repair_timeout=1s + +{{ block "logsBlock" . }} +{{- if hasKey $.component "enabledLogs" }} +enable_logs=true +{{- end }} +{{ end }} \ No newline at end of file diff --git a/deploy/apecloud-mysql/config/mysql-scale-vtgate-config-constraint.cue b/deploy/apecloud-mysql/config/mysql-scale-vtgate-config-constraint.cue index f00bc87aa83..7574311c6bf 100644 --- a/deploy/apecloud-mysql/config/mysql-scale-vtgate-config-constraint.cue +++ b/deploy/apecloud-mysql/config/mysql-scale-vtgate-config-constraint.cue @@ -29,9 +29,15 @@ // Duration for how long a request should be buffered at most. (default 10s) buffer_window: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" - // Enable buffering (stalling) of primary traffic during failovers. + // Enable buffering (stalling) of primary traffic during failovers. (default false) enable_buffer: bool + // Enable or disable logs. (default true) + enable_logs: bool + + // Enable or disable query log. (default true) + enable_query_log: bool + // At startup, the tabletGateway will wait up to this duration to get at least one tablet per keyspace/shard/tablet type. (default 30s) gateway_initial_tablet_timeout: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" @@ -62,6 +68,21 @@ // Tablet refresh interval. (default 1m0s) tablet_refresh_interval: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" + //Which auth server implementation to use. Options: none, static, mysqlbased. (default "none") + mysql_auth_server_impl: string &"none" | "static" | "mysqlbased" + + //JSON File to read the users/passwords from, need set mysql_auth_server_impl to static. + mysql_auth_server_static_file: string + + //Path to ssl key for mysql server plugin SSL + mysql_server_ssl_key: string + + //Path to the ssl cert for mysql server plugin SSL + mysql_server_ssl_cert: string + + //Reject insecure connections but only if mysql_server_ssl_cert and mysql_server_ssl_key are provided.(default "false") + mysql_server_require_secure_transport: bool + ... } diff --git a/deploy/apecloud-mysql/config/mysql-scale-vtgate-config.tpl b/deploy/apecloud-mysql/config/mysql-scale-vtgate-config.tpl index 93b493f7d35..4118374e420 100644 --- a/deploy/apecloud-mysql/config/mysql-scale-vtgate-config.tpl +++ b/deploy/apecloud-mysql/config/mysql-scale-vtgate-config.tpl @@ -13,4 +13,18 @@ enable_buffer=false buffer_size=10000 buffer_window=30s buffer_max_failover_duration=60s -buffer_min_time_between_failovers=60s \ No newline at end of file +buffer_min_time_between_failovers=60s +mysql_auth_server_impl=none +mysql_server_require_secure_transport=false +mysql_auth_server_static_file= +mysql_server_ssl_key= +mysql_server_ssl_cert= + +{{ block "logsBlock" . }} +{{- if hasKey $.component "enabledLogs" }} +enable_logs=true +{{- if mustHas "queryLog" $.component.enabledLogs }} +enable_query_log=true +{{- end }} +{{- end }} +{{ end }} \ No newline at end of file diff --git a/deploy/apecloud-mysql/config/mysql-scale-vttablet-config-constraint.cue b/deploy/apecloud-mysql/config/mysql-scale-vttablet-config-constraint.cue index 488e27b2e0d..a4b3d41026f 100644 --- a/deploy/apecloud-mysql/config/mysql-scale-vttablet-config-constraint.cue +++ b/deploy/apecloud-mysql/config/mysql-scale-vttablet-config-constraint.cue @@ -20,6 +20,12 @@ // Connection timeout to mysqld in milliseconds. (0 for no timeout, default 500) db_connect_timeout_ms: int & >=0 + // Enable or disable logs. (default true) + enable_logs: bool + + // Enable or disable query log. (default true) + enable_query_log: bool + // Interval between health checks. (default 20s) health_check_interval: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" @@ -29,9 +35,21 @@ // Delay between retries of updates to keep the tablet and its shard record in sync. (default 30s) shard_sync_retry_delay: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" - // table acl config mode. Valid values are: simple, mysqlbased. (default simple) + // Table acl config mode. Valid values are: simple, mysqlbased. (default simple) table_acl_config_mode: string & "simple" | "mysqlbased" + // path to table access checker config file (json file); + table_acl_config: string + + // Ticker to reload ACLs. Duration flag, format e.g.: 30s. Default: 30s + table_acl_config_reload_interval: =~"[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" + + // only allow queries that pass table acl checks if true + queryserver_config_strict_table_acl: bool + + // if this flag is true, vttablet will fail to start if a valid tableacl config does not exist + enforce_tableacl_config: bool + ... } diff --git a/deploy/apecloud-mysql/config/mysql-scale-vttablet-config.tpl b/deploy/apecloud-mysql/config/mysql-scale-vttablet-config.tpl index d6aa936b3c7..6dd7c1668ce 100644 --- a/deploy/apecloud-mysql/config/mysql-scale-vttablet-config.tpl +++ b/deploy/apecloud-mysql/config/mysql-scale-vttablet-config.tpl @@ -3,4 +3,10 @@ health_check_interval=1s shard_sync_retry_delay=1s remote_operation_timeout=1s db_connect_timeout_ms=500 -table_acl_config_mode=simple \ No newline at end of file +table_acl_config_mode=simple +enable_logs=true +enable_query_log=true +table_acl_config= +queryserver_config_strict_table_acl=false +table_acl_config_reload_interval=30s +enforce_tableacl_config=false \ No newline at end of file diff --git a/deploy/apecloud-mysql/templates/clusterdefinition.yaml b/deploy/apecloud-mysql/templates/clusterdefinition.yaml index 75829b03a1f..af6f0c6c044 100644 --- a/deploy/apecloud-mysql/templates/clusterdefinition.yaml +++ b/deploy/apecloud-mysql/templates/clusterdefinition.yaml @@ -263,6 +263,8 @@ spec: mountPath: /scripts - name: mysql-scale-config mountPath: /conf + - name: data + mountPath: /vtdataroot volumes: - name: log-data hostPath: @@ -356,7 +358,7 @@ spec: volumeName: mysql-scale-config namespace: {{ .Release.Namespace }} logConfigs: - {{- range $name,$pattern := .Values.etcdLogConfigs }} + {{- range $name,$pattern := .Values.vtconsensusLogConfigs }} - name: {{ $name }} filePathPattern: {{ $pattern }} {{- end }} @@ -373,6 +375,42 @@ spec: targetPort: vtctld-grpcport podSpec: containers: + - name: vtconsensus + imagePullPolicy: {{ default "IfNotPresent" .Values.wesqlscale.image.pullPolicy }} + ports: + - containerPort: 16000 + name: port + env: + - name: CELL + value: {{ .Values.wesqlscale.cell | default "zone1" | quote }} + - 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 + - name: VTCONSENSUS_PORT + value: "16000" + - name: ETCD_SERVER + value: "localhost" + - 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" + command: ["/scripts/vtconsensus.sh"] + volumeMounts: + - name: scripts + mountPath: /scripts + - name: mysql-scale-config + mountPath: /conf + - name: data + mountPath: /vtdataroot - name: etcd imagePullPolicy: {{ default "IfNotPresent" .Values.wesqlscale.image.pullPolicy }} ports: @@ -394,7 +432,7 @@ spec: - name: scripts mountPath: /scripts - name: data - mountPath: /vtdataroot/etcd + mountPath: /vtdataroot lifecycle: postStart: exec: @@ -425,40 +463,8 @@ spec: volumeMounts: - name: scripts mountPath: /scripts - - name: vtconsensus - imagePullPolicy: {{ default "IfNotPresent" .Values.wesqlscale.image.pullPolicy }} - ports: - - containerPort: 16000 - name: port - env: - - name: CELL - value: {{ .Values.wesqlscale.cell | default "zone1" | quote }} - - 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 - - name: VTCONSENSUS_PORT - value: "16000" - - name: ETCD_SERVER - value: "localhost" - - 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" - command: ["/scripts/vtconsensus.sh"] - volumeMounts: - - name: scripts - mountPath: /scripts - - name: mysql-scale-config - mountPath: /conf + - name: data + mountPath: /vtdataroot - name: vtgate characterType: mysql workloadType: Stateless diff --git a/deploy/apecloud-mysql/templates/scripts.yaml b/deploy/apecloud-mysql/templates/scripts.yaml index ae19789f6fe..ef49965c00b 100644 --- a/deploy/apecloud-mysql/templates/scripts.yaml +++ b/deploy/apecloud-mysql/templates/scripts.yaml @@ -24,7 +24,7 @@ data: if [[ $line =~ ^[a-zA-Z_][a-zA-Z0-9_]*=[a-zA-Z0-9_.]*$ ]]; then echo $line eval "export $line" - elif ! [[ $line =~ ^[[:space:]]*# ]]; then + elif ! [[ -z $line || $line =~ ^[[:space:]]*# ]]; then echo "bad format: $line" fi done <<< "$(echo -e "$config_content")" @@ -211,12 +211,14 @@ data: echo "starting vttablet for $alias..." + VTDATAROOT=$VTDATAROOT/vttablet su vitess <