Documentation ¶
Index ¶
- Variables
- func RunCloneCommand(cfg *Config) error
- func RunConfigCommand(cfg *Config) error
- func RunSidecarCommand(cfg *Config, stop <-chan struct{}) error
- func RunTakeBackupCommand(cfg *Config, srcHost, destBucket string) error
- type Config
- func (cfg *Config) ClusterFQDN() string
- func (cfg *Config) FQDNForServer(id int) string
- func (cfg *Config) IsFirstPodInSet() bool
- func (cfg *Config) MasterFQDN() string
- func (cfg *Config) MysqlDSN() string
- func (cfg *Config) RcloneArgs() []string
- func (cfg *Config) ReplicasFQDN() string
- func (cfg *Config) ServerID() int
- func (cfg *Config) ShouldCloneFromBucket() bool
- func (cfg *Config) XbstreamArgs() []string
- func (cfg *Config) XtrabackupArgs() []string
- func (cfg *Config) XtrabackupPrepareArgs() []string
Constants ¶
This section is empty.
Variables ¶
var (
// MysqlServerIDOffset represents the offset with which all server ids are shifted from 0
MysqlServerIDOffset = 100
)
Functions ¶
func RunCloneCommand ¶
RunCloneCommand clones the data from several potential sources.
There are a few possible scenarios that this function tries to handle:
Scenario | Action Taken
------------------------------------------------------------------------------------ Data already exists | Log an informational message and return without error.
| This permits the pod to continue initializing and mysql | will use the data already on the PVC.
------------------------------------------------------------------------------------ Healthy replicas exist | We will attempt to clone from the healthy replicas.
| If the cloning starts but is interrupted, we will return | with an error, not trying to clone from the master. The | assumption is that some intermittent error caused the | failure and we should let K8S restart the init container | to try to clone from the replicas again.
------------------------------------------------------------------------------------ No healthy replicas; only | We attempt to clone from the master, assuming that this master exists | is the initialization of the second pod in a multi-pod
| cluster. If cloning starts and is interrupted, we will | return with an error, letting K8S try again.
------------------------------------------------------------------------------------ No healthy replicas; no | If there is a bucket URL to clone from, we will try that. master; bucket URL exists | The assumption is that this is the bootstrap case: the
| very first mysql pod is being initialized.
------------------------------------------------------------------------------------ No healthy replicas; no | If this is the first pod in the cluster, then allow it master; no bucket URL | to initialize as an empty instance, otherwise, return an
| error to allow k8s to kill and restart the pod.
------------------------------------------------------------------------------------
func RunConfigCommand ¶
RunConfigCommand generates my.cnf, client.cnf and 10-dynamic.cnf files. nolint: gocyclo
func RunSidecarCommand ¶
RunSidecarCommand is the main command, and represents the runtime helper that configures the mysql server
func RunTakeBackupCommand ¶
RunTakeBackupCommand starts a backup command
Types ¶
type Config ¶
type Config struct { // Hostname represents the pod hostname Hostname string // ClusterName is the MySQL cluster name ClusterName string // Namespace represents the namespace where the pod is in Namespace string // ServiceName is the name of the headless service ServiceName string // InitBucketURL represents the init bucket to initialize mysql InitBucketURL string // OperatorUser represents the credentials that the operator will use to connect to the mysql OperatorUser string OperatorPassword string // backup user and password for http endpoint BackupUser string BackupPassword string // replication user and password ReplicationUser string ReplicationPassword string // metrics exporter user and password MetricsUser string MetricsPassword string // orchestrator credentials OrchestratorUser string OrchestratorPassword string // heartbeat credentials HeartBeatUser string HeartBeatPassword string // ExistsMySQLData checks if MySQL data is initialized by checking if the mysql dir exists ExistsMySQLData bool // Offset for assigning MySQL Server ID MyServerIDOffset int // RcloneExtraArgs is a list of extra command line arguments to pass to rclone. RcloneExtraArgs []string // XbstreamExtraArgs is a list of extra command line arguments to pass to xbstream. XbstreamExtraArgs []string // XtrabackupExtraArgs is a list of extra command line arguments to pass to xtrabackup. XtrabackupExtraArgs []string // XtrabackupPrepareExtraArgs is a list of extra command line arguments to pass to xtrabackup // during --prepare. XtrabackupPrepareExtraArgs []string // XtrabackupTargetDir is a backup destination directory for xtrabackup. XtrabackupTargetDir string // InitFileExtraSQL is a list of extra sql commands to append to init_file. InitFileExtraSQL []string // contains filtered or unexported fields }
Config contains information related with the pod.
func NewConfig ¶
func NewConfig() *Config
NewConfig returns a pointer to Config configured from environment variables
func (*Config) ClusterFQDN ¶
ClusterFQDN returns the cluster FQ Name of the cluster from which the node belongs
func (*Config) FQDNForServer ¶
FQDNForServer returns the pod hostname for given MySQL server id
func (*Config) IsFirstPodInSet ¶
IsFirstPodInSet returns true if this pod has an ordinal of 0, meaning it is the first one in the set
func (*Config) MasterFQDN ¶
MasterFQDN the FQ Name of the cluster's master
func (*Config) RcloneArgs ¶
RcloneArgs returns a complete set of rclone arguments.
func (*Config) ReplicasFQDN ¶
ReplicasFQDN the FQ Name of the replicas service
func (*Config) ShouldCloneFromBucket ¶
ShouldCloneFromBucket returns true if it's time to initialize from a bucket URL provided
func (*Config) XbstreamArgs ¶
XbstreamArgs returns a complete set of xbstream arguments.
func (*Config) XtrabackupArgs ¶
XtrabackupArgs returns a complete set of xtrabackup arguments.
func (*Config) XtrabackupPrepareArgs ¶
XtrabackupPrepareArgs returns a complete set of xtrabackup arguments during --prepare.