sidecar

package
Version: v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MysqlServerIDOffset represents the offset with which all server ids are shifted from 0
	MysqlServerIDOffset = 100
)

Functions

func RunCloneCommand

func RunCloneCommand(cfg *Config) error

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

func RunConfigCommand(cfg *Config) error

RunConfigCommand generates my.cnf, client.cnf and 10-dynamic.cnf files. nolint: gocyclo

func RunSidecarCommand

func RunSidecarCommand(cfg *Config, stop <-chan struct{}) error

RunSidecarCommand is the main command, and represents the runtime helper that configures the mysql server

func RunTakeBackupCommand

func RunTakeBackupCommand(cfg *Config, srcHost, destBucket string) error

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

func (cfg *Config) ClusterFQDN() string

ClusterFQDN returns the cluster FQ Name of the cluster from which the node belongs

func (*Config) FQDNForServer

func (cfg *Config) FQDNForServer(id int) string

FQDNForServer returns the pod hostname for given MySQL server id

func (*Config) IsFirstPodInSet added in v0.4.0

func (cfg *Config) IsFirstPodInSet() bool

IsFirstPodInSet returns true if this pod has an ordinal of 0, meaning it is the first one in the set

func (*Config) MasterFQDN

func (cfg *Config) MasterFQDN() string

MasterFQDN the FQ Name of the cluster's master

func (*Config) MysqlDSN

func (cfg *Config) MysqlDSN() string

MysqlDSN returns the connection string to MySQL server

func (*Config) RcloneArgs added in v0.4.0

func (cfg *Config) RcloneArgs() []string

RcloneArgs returns a complete set of rclone arguments.

func (*Config) ReplicasFQDN added in v0.4.0

func (cfg *Config) ReplicasFQDN() string

ReplicasFQDN the FQ Name of the replicas service

func (*Config) ServerID

func (cfg *Config) ServerID() int

ServerID returns the MySQL server id

func (*Config) ShouldCloneFromBucket added in v0.3.0

func (cfg *Config) ShouldCloneFromBucket() bool

ShouldCloneFromBucket returns true if it's time to initialize from a bucket URL provided

func (*Config) XbstreamArgs added in v0.4.0

func (cfg *Config) XbstreamArgs() []string

XbstreamArgs returns a complete set of xbstream arguments.

func (*Config) XtrabackupArgs added in v0.4.0

func (cfg *Config) XtrabackupArgs() []string

XtrabackupArgs returns a complete set of xtrabackup arguments.

func (*Config) XtrabackupPrepareArgs added in v0.4.0

func (cfg *Config) XtrabackupPrepareArgs() []string

XtrabackupPrepareArgs returns a complete set of xtrabackup arguments during --prepare.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL