From 6f30ccb6459fba6610b613a9773850bdf23d6a56 Mon Sep 17 00:00:00 2001 From: acekingke Date: Tue, 18 Jan 2022 15:23:15 +0800 Subject: [PATCH 1/4] cluster,config,sidecar,utils: support the MySQL8.0 #176 --- Makefile | 3 +- .../mysql_v1alpha1_mysqlcluster_mysql8.yaml | 76 +++++++++++ docs/en-us/deploy_radondb_mysql8.md | 10 ++ mysqlcluster/container/init_mysql.go | 3 +- mysqlcluster/container/init_mysql_test.go | 2 +- mysqlcluster/mysqlcluster.go | 22 +++- mysqlcluster/mysqlcluster_test.go | 26 ++-- mysqlcluster/syncer/config_map.go | 26 +++- mysqlcluster/syncer/statefulset.go | 3 + mysqlcluster/syncer/variables.go | 118 +++++++++--------- sidecar/config.go | 43 +++++-- sidecar/init.go | 73 ++++++++--- utils/constants.go | 5 + 13 files changed, 302 insertions(+), 108 deletions(-) create mode 100644 config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml create mode 100644 docs/en-us/deploy_radondb_mysql8.md diff --git a/Makefile b/Makefile index 15e5cabc..e01a0388 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,8 @@ docker-build: test ## Build docker image with the manager. docker build -t ${IMG} . docker build -f Dockerfile.sidecar -t ${SIDECAR_IMG} . docker build -f hack/xenon/Dockerfile -t ${XENON_IMG} hack/xenon - +mysql8-sidecar: + docker build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80 -f Dockerfile.sidecar -t ${SIDECAR_IMG} . docker-push: ## Push docker image with the manager. docker push ${IMG} docker push ${SIDECAR_IMG} diff --git a/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml b/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml new file mode 100644 index 00000000..c27569dd --- /dev/null +++ b/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml @@ -0,0 +1,76 @@ +apiVersion: mysql.radondb.com/v1alpha1 +kind: MysqlCluster +metadata: + name: mysql8-sample +spec: + replicas: 3 + mysqlVersion: "8.0" + # the backupSecretName specify the secret file name which store S3 information, + # if you want S3 backup or restore, please create backup_secret.yaml, uncomment below and fill secret name: + # backupSecretName: + + # if you want create mysqlcluster from S3, uncomment and fill the directory in S3 bucket below: + # restoreFrom: "backup_2022324174848" + mysqlOpts: + rootPassword: "RadonDB@123" + rootHost: localhost + user: radondb_usr + password: RadonDB@123 + database: radondb + # A simple map between string and string. + # Such as: + # mysqlConf: + # expire_logs_days: "7" + mysqlConf: {} + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: 500m + memory: 1Gi + xenonOpts: + image: radondb/xenon:1.1.5-alpha + admitDefeatHearbeatCount: 5 + electionTimeout: 10000 + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + cpu: 100m + memory: 256Mi + metricsOpts: + enabled: false + image: prom/mysqld-exporter:v0.12.1 + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 100m + memory: 128Mi + podPolicy: + imagePullPolicy: Always + sidecarImage: radondb/mysql80-sidecar:v2.2.0 + busyboxImage: busybox:1.32 + slowLogTail: false + auditLogTail: false + labels: {} + annotations: {} + affinity: {} + priorityClassName: "" + tolerations: [] + schedulerName: "" + # extraResources defines quotas for containers other than mysql or xenon. + extraResources: + requests: + cpu: 10m + memory: 32Mi + persistence: + enabled: true + accessModes: + - ReadWriteOnce + #storageClass: "" + size: 20Gi + backupSecretName: sample-backup-secret diff --git a/docs/en-us/deploy_radondb_mysql8.md b/docs/en-us/deploy_radondb_mysql8.md new file mode 100644 index 00000000..c36b0d4e --- /dev/null +++ b/docs/en-us/deploy_radondb_mysql8.md @@ -0,0 +1,10 @@ +# Deploy +use sample `config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml` , modify the `spec.podPolicy.sidecarImage` to MySQL8 version sidecar image. +install step +[deploy reference](deploy_radondb-mysql_operator_on_kubesphere.md) +# How to build sidecar images? +After you had installed docker , use command: +``` +make mysql8-sidecar +``` +it will build mysql8 sidecar image.Then `docker push xxx` to push to docker hub. \ No newline at end of file diff --git a/mysqlcluster/container/init_mysql.go b/mysqlcluster/container/init_mysql.go index b43992ef..d02d3dab 100644 --- a/mysqlcluster/container/init_mysql.go +++ b/mysqlcluster/container/init_mysql.go @@ -44,7 +44,8 @@ func (c *initMysql) getImage() string { // getCommand get the container command. func (c *initMysql) getCommand() []string { - return nil + // Because initialize mysql contain error, so do it in commands. + return []string{"sh", "-c", "/docker-entrypoint.sh mysqld;if test -f /docker-entrypoint-initdb.d/special.sh; then /docker-entrypoint-initdb.d/special.sh; fi "} } // getEnvVars get the container env. diff --git a/mysqlcluster/container/init_mysql_test.go b/mysqlcluster/container/init_mysql_test.go index 6b51d9b4..db729af1 100644 --- a/mysqlcluster/container/init_mysql_test.go +++ b/mysqlcluster/container/init_mysql_test.go @@ -115,7 +115,7 @@ func TestGetInitMysqlImage(t *testing.T) { } func TestGetInitMysqlCommand(t *testing.T) { - assert.Nil(t, initMysqlCase.Command) + assert.Equal(t, initMysqlCase.Command, []string{"sh", "-c", "/docker-entrypoint.sh mysqld;if test -f /docker-entrypoint-initdb.d/special.sh; then /docker-entrypoint-initdb.d/special.sh; fi "}) } func TestGetInitMysqlEnvVar(t *testing.T) { diff --git a/mysqlcluster/mysqlcluster.go b/mysqlcluster/mysqlcluster.go index ddbb7ee0..46e6603b 100644 --- a/mysqlcluster/mysqlcluster.go +++ b/mysqlcluster/mysqlcluster.go @@ -70,7 +70,12 @@ func (c *MysqlCluster) Validate() error { if utils.StringInArray(c.Spec.MysqlOpts.User, []string{"root", utils.ReplicationUser, utils.OperatorUser, utils.MetricsUser}) { return fmt.Errorf("spec.mysqlOpts.user cannot be root|%s|%s|%s", utils.ReplicationUser, utils.OperatorUser, utils.MetricsUser) } - + // MySQL8 nerver support TokuDB + // https://www.percona.com/blog/2021/05/21/tokudb-support-changes-and-future-removal-from-percona-server-for-mysql-8-0/ + if c.Spec.MysqlVersion == "8.0" && c.Spec.MysqlOpts.InitTokuDB { + log.Info("TokuDB is not supported in MySQL 8.0 any more, the value in Cluster.spec.mysqlOpts.initTokuDB should be set false") + return nil + } // https://github.com/percona/percona-docker/blob/main/percona-server-5.7/ps-entry.sh#L159 // ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'127.0.0.1'. if c.Spec.MysqlOpts.RootHost == "127.0.0.1" { @@ -91,12 +96,17 @@ func (c *MysqlCluster) GetLabels() labels.Set { if comp, ok := c.Annotations["app.kubernetes.io/component"]; ok { component = comp } - + // version := "" + // if _, ok := c.Labels["app.kubernetes.io/version"]; !ok { + // version = c.GetMySQLVersion() + // } labels := labels.Set{ - "mysql.radondb.com/cluster": c.Name, - "app.kubernetes.io/name": "mysql", - "app.kubernetes.io/instance": instance, - "app.kubernetes.io/version": c.GetMySQLVersion(), + "mysql.radondb.com/cluster": c.Name, + "app.kubernetes.io/name": "mysql", + "app.kubernetes.io/instance": instance, + // Notice: if app.kubernetes.io/version changed, then statefulset update will failure, It is not need to do this. + // So delete this label. + //"app.kubernetes.io/version": version, "app.kubernetes.io/component": component, "app.kubernetes.io/managed-by": "mysql.radondb.com", } diff --git a/mysqlcluster/mysqlcluster_test.go b/mysqlcluster/mysqlcluster_test.go index e6baf956..2349bdc3 100644 --- a/mysqlcluster/mysqlcluster_test.go +++ b/mysqlcluster/mysqlcluster_test.go @@ -72,10 +72,10 @@ func TestGetLabel(t *testing.T) { &testMysqlCluster, } want := labels.Set{ - "mysql.radondb.com/cluster": "sample", - "app.kubernetes.io/name": "mysql", - "app.kubernetes.io/instance": "instance", - "app.kubernetes.io/version": "5.7.34", + "mysql.radondb.com/cluster": "sample", + "app.kubernetes.io/name": "mysql", + "app.kubernetes.io/instance": "instance", + //"app.kubernetes.io/version": "5.7.34", "app.kubernetes.io/component": "database", "app.kubernetes.io/managed-by": "mysql.radondb.com", } @@ -91,10 +91,10 @@ func TestGetLabel(t *testing.T) { &testMysqlCluster, } want := labels.Set{ - "mysql.radondb.com/cluster": "sample", - "app.kubernetes.io/name": "mysql", - "app.kubernetes.io/instance": "sample", - "app.kubernetes.io/version": "5.7.34", + "mysql.radondb.com/cluster": "sample", + "app.kubernetes.io/name": "mysql", + "app.kubernetes.io/instance": "sample", + //"app.kubernetes.io/version": "5.7.34", "app.kubernetes.io/component": "component", "app.kubernetes.io/managed-by": "mysql.radondb.com", } @@ -110,10 +110,10 @@ func TestGetLabel(t *testing.T) { &testMysqlCluster, } want := labels.Set{ - "mysql.radondb.com/cluster": "sample", - "app.kubernetes.io/name": "mysql", - "app.kubernetes.io/instance": "sample", - "app.kubernetes.io/version": "5.7.34", + "mysql.radondb.com/cluster": "sample", + "app.kubernetes.io/name": "mysql", + "app.kubernetes.io/instance": "sample", + //"app.kubernetes.io/version": "5.7.34", "app.kubernetes.io/component": "database", "app.kubernetes.io/managed-by": "mysql.radondb.com", "app.kubernetes.io/part-of": "part-of", @@ -139,7 +139,7 @@ func TestGetMySQLVersion(t *testing.T) { testCase := MysqlCluster{ &testMysqlCluster, } - want := utils.InvalidMySQLVersion + want := "8.0.25" assert.Equal(t, want, testCase.GetMySQLVersion()) } // MySQLTagsToSemVer 5.7 -> 5.7.34 diff --git a/mysqlcluster/syncer/config_map.go b/mysqlcluster/syncer/config_map.go index b0585d01..09708799 100644 --- a/mysqlcluster/syncer/config_map.go +++ b/mysqlcluster/syncer/config_map.go @@ -51,8 +51,13 @@ func NewConfigMapSyncer(cli client.Client, c *mysqlcluster.MysqlCluster) syncer. return fmt.Errorf("failed to create mysql configs: %s", err) } + dataSpecial, err := buildMysqlSpecialConf(c) + if err != nil { + return fmt.Errorf("failed to create mysql special configs: %s", err) + } cm.Data = map[string]string{ - "my.cnf": data, + "my.cnf": data, + utils.SpecialConfig: dataSpecial, } return nil @@ -65,7 +70,10 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) { sec := cfg.Section("mysqld") c.EnsureMysqlConf() - + if c.Spec.MysqlVersion == "8.0" { + delete(mysqlCommonConfigs, "query_cache_size") + delete(mysqlStaticConfigs, "query_cache_type") + } addKVConfigsToSection(sec, mysqlSysConfigs, mysqlCommonConfigs, mysqlStaticConfigs, c.Spec.MysqlOpts.MysqlConf) if c.Spec.MysqlOpts.InitTokuDB { @@ -86,6 +94,20 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) { return data, nil } +// Build the Special Cnf file. +func buildMysqlSpecialConf(c *mysqlcluster.MysqlCluster) (string, error) { + cfg := ini.Empty(ini.LoadOptions{IgnoreInlineComment: true}) + sec := cfg.Section("mysqld") + + addKVConfigsToSection(sec, specialConfigs) + data, err := writeConfigs(cfg) + if err != nil { + return "", err + } + + return data, nil +} + // addKVConfigsToSection add a map[string]string to a ini.Section func addKVConfigsToSection(s *ini.Section, extraMysqld ...map[string]string) { for _, extra := range extraMysqld { diff --git a/mysqlcluster/syncer/statefulset.go b/mysqlcluster/syncer/statefulset.go index 15bef66a..5a7c2419 100644 --- a/mysqlcluster/syncer/statefulset.go +++ b/mysqlcluster/syncer/statefulset.go @@ -22,6 +22,7 @@ import ( "fmt" "time" + "github.com/go-test/deep" "github.com/iancoleman/strcase" "github.com/imdario/mergo" "github.com/presslabs/controller-util/mergo/transformers" @@ -271,6 +272,8 @@ func (s *StatefulSetSyncer) createOrUpdate(ctx context.Context) (controllerutil. if equality.Semantic.DeepEqual(existing, s.sfs) { return controllerutil.OperationResultNone, nil } + log.Info("update statefulset", "name", s.Name, "diff", deep.Equal(existing, s.sfs)) + // If changed, update statefulset. if err := s.cli.Update(ctx, s.sfs); err != nil { return controllerutil.OperationResultNone, err diff --git a/mysqlcluster/syncer/variables.go b/mysqlcluster/syncer/variables.go index 652e0c39..2588baca 100644 --- a/mysqlcluster/syncer/variables.go +++ b/mysqlcluster/syncer/variables.go @@ -17,9 +17,8 @@ limitations under the License. package syncer import ( - logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/radondb/radondb-mysql-kubernetes/utils" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) // log is for logging in this package. @@ -27,76 +26,83 @@ var log = logf.Log.WithName("mysqlcluster.syncer") // mysqlSysConfigs is the map of mysql system configs. var mysqlSysConfigs = map[string]string{ - "default-time-zone": "+08:00", - "slow_query_log_file": "/var/log/mysql/mysql-slow.log", - "read_only": "ON", - "binlog_format": "row", + "default-time-zone": "+08:00", + "slow_query_log_file": "/var/log/mysql/mysql-slow.log", + "read_only": "ON", + "binlog_format": "row", + "log-bin": "/var/lib/mysql/mysql-bin", + "log-timestamps": "SYSTEM", + "innodb_open_files": "655360", + "open_files_limit": "655360", + + "gtid-mode": "ON", + "enforce-gtid-consistency": "ON", + "slave_parallel_type": "LOGICAL_CLOCK", + "relay_log": "/var/lib/mysql/mysql-relay-bin", + "relay_log_index": "/var/lib/mysql/mysql-relay-bin.index", + "master_info_repository": "TABLE", + "relay_log_info_repository": "TABLE", + "slow_query_log": "1", + "tmp_table_size": "32M", + "tmpdir": "/var/lib/mysql", +} + +var specialConfigs = map[string]string{ "plugin-load": "\"semisync_master.so;semisync_slave.so;audit_log.so;connection_control.so\"", - "log-bin": "/var/lib/mysql/mysql-bin", - "log-timestamps": "SYSTEM", - "innodb_open_files": "655360", - "open_files_limit": "655360", + "audit_log_file": "/var/log/mysql/mysql-audit.log", + "audit_log_exclude_accounts": "\"root@localhost,root@127.0.0.1," + utils.ReplicationUser + "@%," + utils.MetricsUser + "@%\"", + "audit_log_buffer_size": "16M", "rpl_semi_sync_master_enabled": "OFF", "rpl_semi_sync_slave_enabled": "ON", "rpl_semi_sync_master_wait_no_slave": "ON", "rpl_semi_sync_master_timeout": "1000000000000000000", - "gtid-mode": "ON", - "enforce-gtid-consistency": "ON", - "slave_parallel_type": "LOGICAL_CLOCK", - "relay_log": "/var/lib/mysql/mysql-relay-bin", - "relay_log_index": "/var/lib/mysql/mysql-relay-bin.index", - "master_info_repository": "TABLE", - "relay_log_info_repository": "TABLE", - "relay_log_recovery": "ON", - "slow_query_log": "1", - "tmp_table_size": "32M", - "tmpdir": "/var/lib/mysql", - "audit_log_file": "/var/log/mysql/mysql-audit.log", - "audit_log_exclude_accounts": "\"root@localhost,root@127.0.0.1," + utils.ReplicationUser + "@%," + utils.MetricsUser + "@%\"", - "audit_log_buffer_size": "16M", -} - -// mysqlCommonConfigs is the map of the mysql common configs. -var mysqlCommonConfigs = map[string]string{ - "character_set_server": "utf8mb4", - "interactive_timeout": "3600", - "default-time-zone": "+08:00", - "expire_logs_days": "7", - "key_buffer_size": "33554432", - "log_bin_trust_function_creators": "1", - "long_query_time": "3", - "binlog_cache_size": "32768", - "binlog_stmt_cache_size": "32768", - "max_connections": "1024", - "max_connect_errors": "655360", - "query_cache_size": "0", - "sync_master_info": "1000", - "sync_relay_log": "1000", - "sync_relay_log_info": "1000", - "table_open_cache": "2000", - "thread_cache_size": "128", - "wait_timeout": "3600", - "group_concat_max_len": "1024", - "slave_rows_search_algorithms": "INDEX_SCAN,HASH_SCAN", - "max_allowed_packet": "1073741824", - "event_scheduler": "OFF", - "innodb_print_all_deadlocks": "0", - "autocommit": "1", - "transaction-isolation": "READ-COMMITTED", + //"audit-log": "ON", "audit_log_policy": "NONE", "audit_log_rotate_on_size": "104857600", "audit_log_rotations": "6", + "audit_log_format": "OLD", "connection_control_failed_connections_threshold": "3", "connection_control_min_connection_delay": "1000", "connection_control_max_connection_delay": "2147483647", - "explicit_defaults_for_timestamp": "0", - "innodb_adaptive_hash_index": "0", + "default-authentication-plugin": "mysql_native_password", +} + +// mysqlCommonConfigs is the map of the mysql common configs. +var mysqlCommonConfigs = map[string]string{ + "character_set_server": "utf8mb4", + "interactive_timeout": "3600", + "default-time-zone": "+08:00", + "expire_logs_days": "7", + "key_buffer_size": "33554432", + "log_bin_trust_function_creators": "1", + "long_query_time": "3", + "binlog_cache_size": "32768", + "binlog_stmt_cache_size": "32768", + "max_connections": "1024", + "max_connect_errors": "655360", + "query_cache_size": "0", + "sync_master_info": "1000", + "sync_relay_log": "1000", + "sync_relay_log_info": "1000", + "table_open_cache": "2000", + "thread_cache_size": "128", + "wait_timeout": "3600", + "group_concat_max_len": "1024", + "slave_rows_search_algorithms": "INDEX_SCAN,HASH_SCAN", + "max_allowed_packet": "1073741824", + "event_scheduler": "OFF", + "innodb_print_all_deadlocks": "0", + "autocommit": "1", + "transaction-isolation": "READ-COMMITTED", + + "explicit_defaults_for_timestamp": "0", + "innodb_adaptive_hash_index": "0", } // mysqlStaticConfigs is the map of the mysql static configs. // The mysql need restart, if modify the config. var mysqlStaticConfigs = map[string]string{ - "audit_log_format": "OLD", + "default-storage-engine": "InnoDB", "back_log": "2048", "ft_min_word_len": "4", diff --git a/sidecar/config.go b/sidecar/config.go index eeaa5552..51b93193 100644 --- a/sidecar/config.go +++ b/sidecar/config.go @@ -363,23 +363,44 @@ func (cfg *Config) buildInitSql() []byte { sql := fmt.Sprintf(`SET @@SESSION.SQL_LOG_BIN=0; CREATE DATABASE IF NOT EXISTS %s; DROP user IF EXISTS 'root'@'127.0.0.1'; -GRANT ALL ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '%s' with grant option; +CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY '%s'; +GRANT ALL ON *.* TO 'root'@'127.0.0.1' with grant option; DROP user IF EXISTS 'root'@'%%'; -GRANT ALL ON *.* TO 'root'@'%%' IDENTIFIED BY '%s' with grant option; +CREATE USER 'root'@'%%' IDENTIFIED BY '%s'; +GRANT ALL ON *.* TO 'root'@'%%' with grant option; DROP user IF EXISTS '%s'@'%%'; -GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO '%s'@'%%' IDENTIFIED BY '%s'; +CREATE USER '%s'@'%%' IDENTIFIED BY '%s'; +GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO '%s'@'%%'; DROP user IF EXISTS '%s'@'%%'; -GRANT SELECT, PROCESS, REPLICATION CLIENT ON *.* TO '%s'@'%%' IDENTIFIED BY '%s'; +CREATE USER '%s'@'%%' IDENTIFIED BY '%s'; +GRANT SELECT, PROCESS, REPLICATION CLIENT ON *.* TO '%s'@'%%'; DROP user IF EXISTS '%s'@'%%'; -GRANT SUPER, PROCESS, RELOAD, CREATE, SELECT ON *.* TO '%s'@'%%' IDENTIFIED BY '%s'; +CREATE USER '%s'@'%%' IDENTIFIED BY '%s'; +GRANT SUPER, PROCESS, RELOAD, CREATE, SELECT ON *.* TO '%s'@'%%'; DROP user IF EXISTS '%s'@'%%'; -GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s'; +CREATE USER '%s'@'%%' IDENTIFIED BY '%s'; +GRANT ALL ON %s.* TO '%s'@'%%' ; FLUSH PRIVILEGES; -RESET SLAVE ALL; -`, cfg.Database, cfg.RootPassword, cfg.InternalRootPassword, cfg.ReplicationUser, cfg.ReplicationUser, cfg.ReplicationPassword, - cfg.MetricsUser, cfg.MetricsUser, cfg.MetricsPassword, cfg.OperatorUser, cfg.OperatorUser, - cfg.OperatorPassword, cfg.User, cfg.Database, cfg.User, cfg.Password) - +RESET SLAVE ALL; +`, + cfg.Database, //database + cfg.RootPassword, + cfg.InternalRootPassword, + cfg.ReplicationUser, //drop user + cfg.ReplicationUser, cfg.ReplicationPassword, //create user + cfg.ReplicationUser, //grant REPLICATION + + cfg.MetricsUser, //drop user MetricsUser + cfg.MetricsUser, cfg.MetricsPassword, //create user + cfg.MetricsUser, //grant + + cfg.OperatorUser, //drop user + cfg.OperatorUser, cfg.OperatorPassword, //create + cfg.OperatorUser, //grant + + cfg.User, //drop user + cfg.User, cfg.Password, //create user + cfg.Database, cfg.User) //grant return utils.StringToBytes(sql) } diff --git a/sidecar/init.go b/sidecar/init.go index 6b8ba015..25e1cc80 100644 --- a/sidecar/init.go +++ b/sidecar/init.go @@ -25,6 +25,7 @@ import ( "os/user" "path" "strconv" + "strings" "github.com/radondb/radondb-mysql-kubernetes/utils" "github.com/spf13/cobra" @@ -109,26 +110,25 @@ func runCloneAndInit(cfg *Config) error { // runInitCommand do some initialization operations. func runInitCommand(cfg *Config) error { var err error + // Get the mysql user. + user, err := user.Lookup("mysql") + if err != nil { + return fmt.Errorf("failed to get mysql user: %s", err) + } + uid, err := strconv.Atoi(user.Uid) + if err != nil { + return fmt.Errorf("failed to get mysql user uid: %s", err) + } + gid, err := strconv.Atoi(user.Gid) + if err != nil { + return fmt.Errorf("failed to get mysql user gid: %s", err) + } if exists, _ := checkIfPathExists(dataPath); exists { // remove lost+found. if err := os.RemoveAll(dataPath + "/lost+found"); err != nil { return fmt.Errorf("removing lost+found: %s", err) } - - // Get the mysql user. - user, err := user.Lookup("mysql") - if err != nil { - return fmt.Errorf("failed to get mysql user: %s", err) - } - uid, err := strconv.Atoi(user.Uid) - if err != nil { - return fmt.Errorf("failed to get mysql user uid: %s", err) - } - gid, err := strconv.Atoi(user.Gid) - if err != nil { - return fmt.Errorf("failed to get mysql user gid: %s", err) - } // chown -R mysql:mysql /var/lib/mysql. if err = os.Chown(dataPath, uid, gid); err != nil { return fmt.Errorf("failed to chown %s: %s", dataPath, err) @@ -160,6 +160,11 @@ func runInitCommand(cfg *Config) error { } } + // chown -R mysql:mysql /var/lib/mysql. + if err = os.Chown(extraConfPath, uid, gid); err != nil { + return fmt.Errorf("failed to chown %s: %s", dataPath, err) + } + // Run reset master in init-mysql container. if err = ioutil.WriteFile(initFilePath+"/reset.sql", []byte("reset master;"), 0644); err != nil { return fmt.Errorf("failed to write reset.sql: %s", err) @@ -176,9 +181,43 @@ func runInitCommand(cfg *Config) error { if err != nil { return fmt.Errorf("failed to build extra.cnf: %s", err) } - // save extra.cnf to conf.d. - if err := extraConfig.SaveTo(path.Join(extraConfPath, "extra.cnf")); err != nil { - return fmt.Errorf("failed to save extra.cnf: %s", err) + // Notice: special.cnf cannot be copied to extra-conf when initialized. + // check /var/lib/mysql/mysql exists. if exists it means that been initialized. + if exists, _ := checkIfPathExists(path.Join(dataPath, "mysql")); exists || strings.HasPrefix(getEnvValue("MYSQL_VERSION"), "5") { + if err = copyFile(path.Join(configMapPath, utils.SpecialConfig), path.Join(extraConfPath, utils.SpecialConfig)); err != nil { + return fmt.Errorf("failed to copy special.cnf: %s", err) + } + // save extra.cnf to conf.d. + if err := extraConfig.SaveTo(path.Join(extraConfPath, "extra.cnf")); err != nil { + return fmt.Errorf("failed to save extra.cnf: %s", err) + } + } else { + log.Info("mysql is not initialized, use shell script copying special.cnf") + // save extra.cnf to conf.d. + if err := extraConfig.SaveTo(path.Join(initFilePath, "extra.cnf")); err != nil { + return fmt.Errorf("failed to save extra.cnf: %s", err) + } + if err = copyFile(path.Join(configMapPath, utils.SpecialConfig), path.Join(initFilePath, utils.SpecialConfig)); err != nil { + return fmt.Errorf("failed to copy special.cnf: %s", err) + } + src := fmt.Sprintf(`#!/bin/bash +cp %s %s +cp %s %s +chown -R mysql.mysql %s +chown -R mysql.mysql %s`, + // cp special.cnf to /etc/mysql/conf.d/ + path.Join(initFilePath, utils.SpecialConfig), + path.Join(extraConfPath, utils.SpecialConfig), + // cp extra.cnf to /etc/mysql/conf.d/ + path.Join(initFilePath, "extra.cnf"), + path.Join(extraConfPath, "extra.cnf"), + // chown -R mysql.mysql cnf files + path.Join(extraConfPath, utils.SpecialConfig), + path.Join(extraConfPath, "extra.cnf")) + if err = ioutil.WriteFile(initFilePath+"/special.sh", []byte(src), 0755); err != nil { + return fmt.Errorf("failed to write special.sh: %s", err) + } + } // // build leader-start.sh. diff --git a/utils/constants.go b/utils/constants.go index b291caab..f94b9b2d 100644 --- a/utils/constants.go +++ b/utils/constants.go @@ -28,12 +28,14 @@ var ( // MySQLTagsToSemVer maps simple version to semver versions MySQLTagsToSemVer = map[string]string{ "5.7": "5.7.34", + "8.0": "8.0.25", } // MysqlImageVersions is a map of supported mysql version and their image MysqlImageVersions = map[string]string{ "5.7.33": "percona/percona-server:5.7.33", "5.7.34": "percona/percona-server:5.7.34", + "8.0.25": "percona/percona-server:8.0.25", "0.0.0": "errimage", } @@ -129,6 +131,9 @@ const ( // LeaderHost is the alias for leader`s host. LeaderHost = "leader-host" + + // For MySQL8, the configs should deal with alone + SpecialConfig = "special.cnf" ) // ResourceName is the type for aliasing resources that will be created. From 0543c43cc8e62cf311b957333cc3dee2918efc99 Mon Sep 17 00:00:00 2001 From: runkecheng <1131648942@qq.com> Date: Thu, 7 Apr 2022 09:29:44 +0800 Subject: [PATCH 2/4] syncer: Refine the mysql configuration item. 1. Separate the configuration of mysql57 and mysql80, remove discarded parameters in mysql8 config. 2. Rename specialConfigs to PluginConfigs. --- mysqlcluster/syncer/config_map.go | 22 ++++++---- .../syncer/{variables.go => mysql_configs.go} | 42 +++++++++++++------ 2 files changed, 42 insertions(+), 22 deletions(-) rename mysqlcluster/syncer/{variables.go => mysql_configs.go} (87%) diff --git a/mysqlcluster/syncer/config_map.go b/mysqlcluster/syncer/config_map.go index 09708799..a9ca9518 100644 --- a/mysqlcluster/syncer/config_map.go +++ b/mysqlcluster/syncer/config_map.go @@ -51,13 +51,13 @@ func NewConfigMapSyncer(cli client.Client, c *mysqlcluster.MysqlCluster) syncer. return fmt.Errorf("failed to create mysql configs: %s", err) } - dataSpecial, err := buildMysqlSpecialConf(c) + dataPlugin, err := buildMysqlPluginConf(c) if err != nil { - return fmt.Errorf("failed to create mysql special configs: %s", err) + return fmt.Errorf("failed to create mysql plugin configs: %s", err) } cm.Data = map[string]string{ "my.cnf": data, - utils.SpecialConfig: dataSpecial, + utils.PluginConfigs: dataPlugin, } return nil @@ -70,10 +70,14 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) { sec := cfg.Section("mysqld") c.EnsureMysqlConf() - if c.Spec.MysqlVersion == "8.0" { - delete(mysqlCommonConfigs, "query_cache_size") - delete(mysqlStaticConfigs, "query_cache_type") + + switch c.Spec.MysqlVersion { + case "8.0": + addKVConfigsToSection(sec, mysql80Configs) + case "5.7": + addKVConfigsToSection(sec, mysql57Configs) } + addKVConfigsToSection(sec, mysqlSysConfigs, mysqlCommonConfigs, mysqlStaticConfigs, c.Spec.MysqlOpts.MysqlConf) if c.Spec.MysqlOpts.InitTokuDB { @@ -94,12 +98,12 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) { return data, nil } -// Build the Special Cnf file. -func buildMysqlSpecialConf(c *mysqlcluster.MysqlCluster) (string, error) { +// Build the Plugin Cnf file. +func buildMysqlPluginConf(c *mysqlcluster.MysqlCluster) (string, error) { cfg := ini.Empty(ini.LoadOptions{IgnoreInlineComment: true}) sec := cfg.Section("mysqld") - addKVConfigsToSection(sec, specialConfigs) + addKVConfigsToSection(sec, pluginConfigs) data, err := writeConfigs(cfg) if err != nil { return "", err diff --git a/mysqlcluster/syncer/variables.go b/mysqlcluster/syncer/mysql_configs.go similarity index 87% rename from mysqlcluster/syncer/variables.go rename to mysqlcluster/syncer/mysql_configs.go index 2588baca..385b22b3 100644 --- a/mysqlcluster/syncer/variables.go +++ b/mysqlcluster/syncer/mysql_configs.go @@ -40,31 +40,52 @@ var mysqlSysConfigs = map[string]string{ "slave_parallel_type": "LOGICAL_CLOCK", "relay_log": "/var/lib/mysql/mysql-relay-bin", "relay_log_index": "/var/lib/mysql/mysql-relay-bin.index", - "master_info_repository": "TABLE", - "relay_log_info_repository": "TABLE", "slow_query_log": "1", "tmp_table_size": "32M", "tmpdir": "/var/lib/mysql", } -var specialConfigs = map[string]string{ +var pluginConfigs = map[string]string{ "plugin-load": "\"semisync_master.so;semisync_slave.so;audit_log.so;connection_control.so\"", - "audit_log_file": "/var/log/mysql/mysql-audit.log", - "audit_log_exclude_accounts": "\"root@localhost,root@127.0.0.1," + utils.ReplicationUser + "@%," + utils.MetricsUser + "@%\"", - "audit_log_buffer_size": "16M", + "rpl_semi_sync_master_enabled": "OFF", "rpl_semi_sync_slave_enabled": "ON", "rpl_semi_sync_master_wait_no_slave": "ON", "rpl_semi_sync_master_timeout": "1000000000000000000", - //"audit-log": "ON", + + "audit_log_file": "/var/log/mysql/mysql-audit.log", + "audit_log_exclude_accounts": "\"root@localhost,root@127.0.0.1," + utils.ReplicationUser + "@%," + utils.MetricsUser + "@%\"", + "audit_log_buffer_size": "16M", "audit_log_policy": "NONE", "audit_log_rotate_on_size": "104857600", "audit_log_rotations": "6", "audit_log_format": "OLD", + "connection_control_failed_connections_threshold": "3", "connection_control_min_connection_delay": "1000", "connection_control_max_connection_delay": "2147483647", - "default-authentication-plugin": "mysql_native_password", +} + +var mysql57Configs = map[string]string{ + "query-cache-type": "0", + "query-cache-size": "0", + "sql-mode": "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER," + + "NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY", + + "expire-logs-days": "7", + + "master_info_repository": "TABLE", + "relay_log_info_repository": "TABLE", + "slave_rows_search_algorithms": "INDEX_SCAN,HASH_SCAN", +} + +var mysql80Configs = map[string]string{ + "sql-mode": "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION," + + "NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY", + // 7 days = 7 * 24 * 60 * 60 + "binlog_expire_logs_seconds": "604800", + // use 5.7 auth plugin to be backward compatible + "default-authentication-plugin": "mysql_native_password", } // mysqlCommonConfigs is the map of the mysql common configs. @@ -72,7 +93,6 @@ var mysqlCommonConfigs = map[string]string{ "character_set_server": "utf8mb4", "interactive_timeout": "3600", "default-time-zone": "+08:00", - "expire_logs_days": "7", "key_buffer_size": "33554432", "log_bin_trust_function_creators": "1", "long_query_time": "3", @@ -80,7 +100,6 @@ var mysqlCommonConfigs = map[string]string{ "binlog_stmt_cache_size": "32768", "max_connections": "1024", "max_connect_errors": "655360", - "query_cache_size": "0", "sync_master_info": "1000", "sync_relay_log": "1000", "sync_relay_log_info": "1000", @@ -88,7 +107,6 @@ var mysqlCommonConfigs = map[string]string{ "thread_cache_size": "128", "wait_timeout": "3600", "group_concat_max_len": "1024", - "slave_rows_search_algorithms": "INDEX_SCAN,HASH_SCAN", "max_allowed_packet": "1073741824", "event_scheduler": "OFF", "innodb_print_all_deadlocks": "0", @@ -102,12 +120,10 @@ var mysqlCommonConfigs = map[string]string{ // mysqlStaticConfigs is the map of the mysql static configs. // The mysql need restart, if modify the config. var mysqlStaticConfigs = map[string]string{ - "default-storage-engine": "InnoDB", "back_log": "2048", "ft_min_word_len": "4", "lower_case_table_names": "0", - "query_cache_type": "OFF", "innodb_ft_max_token_size": "84", "innodb_ft_min_token_size": "3", "sql_mode": "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION", From 2e82696678be415c67108db645428c342f2855f5 Mon Sep 17 00:00:00 2001 From: runkecheng <1131648942@qq.com> Date: Thu, 7 Apr 2022 09:32:27 +0800 Subject: [PATCH 3/4] sidecar: Optimized mysql configuration application logic. Package the logic of applying configuration to improve code readability. --- sidecar/init.go | 77 ++++++++++++++++++++++++++-------------------- utils/constants.go | 4 +-- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/sidecar/init.go b/sidecar/init.go index 25e1cc80..f0548873 100644 --- a/sidecar/init.go +++ b/sidecar/init.go @@ -27,6 +27,7 @@ import ( "strconv" "strings" + "github.com/go-ini/ini" "github.com/radondb/radondb-mysql-kubernetes/utils" "github.com/spf13/cobra" ) @@ -181,43 +182,24 @@ func runInitCommand(cfg *Config) error { if err != nil { return fmt.Errorf("failed to build extra.cnf: %s", err) } - // Notice: special.cnf cannot be copied to extra-conf when initialized. - // check /var/lib/mysql/mysql exists. if exists it means that been initialized. + + // Notice: plugin.cnf cannot be copied to /etc/mysql/conf.d when initialized. + // Check /var/lib/mysql/mysql exists. if exists it means that been initialized. if exists, _ := checkIfPathExists(path.Join(dataPath, "mysql")); exists || strings.HasPrefix(getEnvValue("MYSQL_VERSION"), "5") { - if err = copyFile(path.Join(configMapPath, utils.SpecialConfig), path.Join(extraConfPath, utils.SpecialConfig)); err != nil { - return fmt.Errorf("failed to copy special.cnf: %s", err) - } - // save extra.cnf to conf.d. - if err := extraConfig.SaveTo(path.Join(extraConfPath, "extra.cnf")); err != nil { - return fmt.Errorf("failed to save extra.cnf: %s", err) - } + // Save plugin.cnf and extra.cnf to /etc/mysql/conf.d. + saveCnfTo(extraConfPath, extraConfig) } else { - log.Info("mysql is not initialized, use shell script copying special.cnf") - // save extra.cnf to conf.d. - if err := extraConfig.SaveTo(path.Join(initFilePath, "extra.cnf")); err != nil { - return fmt.Errorf("failed to save extra.cnf: %s", err) - } - if err = copyFile(path.Join(configMapPath, utils.SpecialConfig), path.Join(initFilePath, utils.SpecialConfig)); err != nil { - return fmt.Errorf("failed to copy special.cnf: %s", err) + log.Info("mysql is not initialized, use shell script copying plugin.cnf") + // Save plugin.cnf and extra.cnf to /docker-entrypoint-initdb.d. + saveCnfTo(initFilePath, extraConfig) + + src := PluginConfigsSh() + // Write plugin.sh to docker-entrypoint-initdb.d/plugin.sh. + // In this way, plugin.sh will be performed automatically when Percona docker-entrypoint.sh is executed. + // plugin.sh will copy plugin.cnf and extra.cnf to /etc/mysql/conf.d. + if err = ioutil.WriteFile(initFilePath+"/plugin.sh", []byte(src), 0755); err != nil { + return fmt.Errorf("failed to write plugin.sh: %s", err) } - src := fmt.Sprintf(`#!/bin/bash -cp %s %s -cp %s %s -chown -R mysql.mysql %s -chown -R mysql.mysql %s`, - // cp special.cnf to /etc/mysql/conf.d/ - path.Join(initFilePath, utils.SpecialConfig), - path.Join(extraConfPath, utils.SpecialConfig), - // cp extra.cnf to /etc/mysql/conf.d/ - path.Join(initFilePath, "extra.cnf"), - path.Join(extraConfPath, "extra.cnf"), - // chown -R mysql.mysql cnf files - path.Join(extraConfPath, utils.SpecialConfig), - path.Join(extraConfPath, "extra.cnf")) - if err = ioutil.WriteFile(initFilePath+"/special.sh", []byte(src), 0755); err != nil { - return fmt.Errorf("failed to write special.sh: %s", err) - } - } // // build leader-start.sh. @@ -285,3 +267,30 @@ func RunRequestBackup(cfg *Config, host string) error { _, err := requestABackup(cfg, host, serverBackupEndpoint) return err } + +// Save plugin.cnf and extra.cnf to specified path. +func saveCnfTo(targetPath string, extraCnf *ini.File) error { + if err := copyFile(path.Join(configMapPath, utils.PluginConfigs), path.Join(targetPath, utils.PluginConfigs)); err != nil { + return fmt.Errorf("failed to copy plugin.cnf: %s", err) + } + if err := extraCnf.SaveTo(path.Join(targetPath, "extra.cnf")); err != nil { + return fmt.Errorf("failed to save extra.cnf: %s", err) + } + return nil +} + +func PluginConfigsSh() string { + return fmt.Sprintf(`#!/bin/bash +cp %s %s +cp %s %s +chown -R mysql.mysql %s +chown -R mysql.mysql %s`, + // cp plugin.cnf to /etc/mysql/conf.d/ + path.Join(initFilePath, utils.PluginConfigs), path.Join(extraConfPath, utils.PluginConfigs), + // cp extra.cnf to /etc/mysql/conf.d/ + path.Join(initFilePath, "extra.cnf"), path.Join(extraConfPath, "extra.cnf"), + // chown -R mysql.mysql plugin.cnf + path.Join(extraConfPath, utils.PluginConfigs), + // chown -R mysql.mysql extra.cnf + path.Join(extraConfPath, "extra.cnf")) +} diff --git a/utils/constants.go b/utils/constants.go index f94b9b2d..f6cf95d7 100644 --- a/utils/constants.go +++ b/utils/constants.go @@ -132,8 +132,8 @@ const ( // LeaderHost is the alias for leader`s host. LeaderHost = "leader-host" - // For MySQL8, the configs should deal with alone - SpecialConfig = "special.cnf" + // + PluginConfigs = "plugin.cnf" ) // ResourceName is the type for aliasing resources that will be created. From 4feba8341428009bb81af72e58bfba8bb33c2668 Mon Sep 17 00:00:00 2001 From: runkecheng <1131648942@qq.com> Date: Thu, 7 Apr 2022 09:33:01 +0800 Subject: [PATCH 4/4] *: Set default version to v2.2.0. 1. Set the default version to v2.2.0. 2. Set the default value of InitTokuDB to false. --- api/v1alpha1/mysqlcluster_types.go | 2 +- .../crds/mysql.radondb.com_backups.yaml | 2 +- .../crds/mysql.radondb.com_mysqlclusters.yaml | 6 ++--- charts/mysql-operator/values.yaml | 2 +- .../samples/mysql_v1alpha1_mysqlcluster.yaml | 2 +- .../mysql_v1alpha1_mysqlcluster_mysql8.yaml | 25 ++++++++++++++----- ...v1alpha1_mysqlcluster_podAntiAffinity.yaml | 2 +- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/api/v1alpha1/mysqlcluster_types.go b/api/v1alpha1/mysqlcluster_types.go index 5565946c..1b47823c 100644 --- a/api/v1alpha1/mysqlcluster_types.go +++ b/api/v1alpha1/mysqlcluster_types.go @@ -120,7 +120,7 @@ type MysqlOpts struct { // InitTokuDB represents if install tokudb engine. // +optional - // +kubebuilder:default:=true + // +kubebuilder:default:=false InitTokuDB bool `json:"initTokuDB,omitempty"` // A map[string]string that will be passed to my.cnf file. diff --git a/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml b/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml index 41b28a39..4b4f2c1c 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml @@ -48,7 +48,7 @@ spec: description: HostName represents the host for which to take backup type: string image: - default: radondb/mysql-sidecar:latest + default: radondb/mysql57-sidecar:v2.2.0 description: To specify the image that will be used for sidecar container. type: string required: diff --git a/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml b/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml index 5b04dd08..fe8d2258 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml @@ -137,7 +137,7 @@ spec: description: Name for new database to create. type: string initTokuDB: - default: true + default: false description: InitTokuDB represents if install tokudb engine. type: boolean mysqlConf: @@ -252,7 +252,7 @@ spec: cpu: 10m memory: 32Mi imagePullPolicy: IfNotPresent - sidecarImage: radondb/mysql-sidecar:latest + sidecarImage: radondb/mysql57-sidecar:v2.2.0 description: PodPolicy defines the policy to extra specification. properties: affinity: @@ -1182,7 +1182,7 @@ spec: schedulerName: type: string sidecarImage: - default: radondb/mysql-sidecar:latest + default: radondb/mysql57-sidecar:v2.2.0 description: To specify the image that will be used for sidecar container. type: string diff --git a/charts/mysql-operator/values.yaml b/charts/mysql-operator/values.yaml index 4213e893..1f3f21e1 100644 --- a/charts/mysql-operator/values.yaml +++ b/charts/mysql-operator/values.yaml @@ -21,7 +21,7 @@ tolerationSeconds: 30 manager: image: radondb/mysql-operator - tag: latest + tag: v2.2.0 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 diff --git a/config/samples/mysql_v1alpha1_mysqlcluster.yaml b/config/samples/mysql_v1alpha1_mysqlcluster.yaml index 3c8ef795..f2c7021d 100644 --- a/config/samples/mysql_v1alpha1_mysqlcluster.yaml +++ b/config/samples/mysql_v1alpha1_mysqlcluster.yaml @@ -62,7 +62,7 @@ spec: podPolicy: imagePullPolicy: IfNotPresent - sidecarImage: radondb/mysql-sidecar:latest + sidecarImage: radondb/mysql57-sidecar:v2.2.0 busyboxImage: busybox:1.32 slowLogTail: false diff --git a/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml b/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml index c27569dd..f1ff88a1 100644 --- a/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml +++ b/config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml @@ -1,27 +1,33 @@ apiVersion: mysql.radondb.com/v1alpha1 kind: MysqlCluster metadata: - name: mysql8-sample + name: sample spec: replicas: 3 mysqlVersion: "8.0" + # the backupSecretName specify the secret file name which store S3 information, # if you want S3 backup or restore, please create backup_secret.yaml, uncomment below and fill secret name: # backupSecretName: - + # if you want create mysqlcluster from S3, uncomment and fill the directory in S3 bucket below: - # restoreFrom: "backup_2022324174848" + # restoreFrom: + mysqlOpts: rootPassword: "RadonDB@123" rootHost: localhost user: radondb_usr password: RadonDB@123 database: radondb + ## tokudb is not supported in mysql8. + # initTokuDB: false + # A simple map between string and string. # Such as: # mysqlConf: # expire_logs_days: "7" mysqlConf: {} + resources: requests: cpu: 100m @@ -29,10 +35,12 @@ spec: limits: cpu: 500m memory: 1Gi + xenonOpts: image: radondb/xenon:1.1.5-alpha admitDefeatHearbeatCount: 5 electionTimeout: 10000 + resources: requests: cpu: 50m @@ -40,9 +48,11 @@ spec: limits: cpu: 100m memory: 256Mi + metricsOpts: enabled: false image: prom/mysqld-exporter:v0.12.1 + resources: requests: cpu: 10m @@ -50,12 +60,15 @@ spec: limits: cpu: 100m memory: 128Mi + podPolicy: - imagePullPolicy: Always + imagePullPolicy: IfNotPresent sidecarImage: radondb/mysql80-sidecar:v2.2.0 busyboxImage: busybox:1.32 + slowLogTail: false auditLogTail: false + labels: {} annotations: {} affinity: {} @@ -67,10 +80,10 @@ spec: requests: cpu: 10m memory: 32Mi + persistence: enabled: true accessModes: - - ReadWriteOnce + - ReadWriteOnce #storageClass: "" size: 20Gi - backupSecretName: sample-backup-secret diff --git a/config/samples/mysql_v1alpha1_mysqlcluster_podAntiAffinity.yaml b/config/samples/mysql_v1alpha1_mysqlcluster_podAntiAffinity.yaml index 107c3b1b..4b1d8fa8 100644 --- a/config/samples/mysql_v1alpha1_mysqlcluster_podAntiAffinity.yaml +++ b/config/samples/mysql_v1alpha1_mysqlcluster_podAntiAffinity.yaml @@ -62,7 +62,7 @@ spec: podPolicy: imagePullPolicy: IfNotPresent - sidecarImage: radondb/mysql-sidecar:latest + sidecarImage: radondb/mysql57-sidecar:v2.2.0 busyboxImage: busybox:1.32 slowLogTail: false