mysql

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AppName         = "mysql"
	DataVolumeName  = "datadir"
	DataMountPath   = "/var/lib/mysql"
	CustomConfigKey = "my.cnf"

	CustomMyCnfPath   = "/etc/mysql/config/my-config.cnf"
	AutoConfigCnfPath = "/etc/mysql/config/auto-config.cnf"
	SecretMyCnfPath   = "/etc/mysql/config/my-secret.cnf"

	TLSMountPath = "/etc/mysql/mysql-tls-secret"
	BackupLogDir = "/var/log/xtrabackup"
)
View Source
const (
	DefaultPort      = 3306
	DefaultGRPort    = 33061
	DefaultAdminPort = 33062
	DefaultXPort     = 33060
	SidecarHTTPPort  = 6450

	DefaultReadTimeoutSecondsSeconds = 3600

	// DefaultCloneTimeoutSeconds is the default for the bootstrap clone timeout
	// (BOOTSTRAP_CLONE_TIMEOUT) when it is not set via spec.mysql.env. It is
	// generous (6h) because multi-TiB clones can run for hours; it is a safety
	// net that lets a genuinely hung clone abort and retry, not a tuning knob.
	DefaultCloneTimeoutSeconds = 21600

	// DefaultCloneStallTimeoutSeconds is the default for the bootstrap clone
	// progress watchdog (BOOTSTRAP_CLONE_STALL_TIMEOUT): the clone is aborted
	// only if it transfers no bytes for this long. A progressing clone runs
	// unbounded; set the env to 0 (via spec.mysql.env) to disable the watchdog.
	DefaultCloneStallTimeoutSeconds = 900

	DefaultAsyncSourceRetryCount   = 3
	DefaultAsyncSourceConnectRetry = 60

	DatetimeFormat = "2006-01-02 15:04:05"
)

Variables

View Source
var ErrInsufficientStorage = errors.New("data volume is too small for the calculated configuration")

ErrInsufficientStorage reports that the data volume cannot host the redo log the calculated configuration asks for.

View Source
var (
	ErrNoReadyPods = errors.New("no ready pods")
)
View Source
var ErrRolloutInProgress = errors.New("rollout in progress")

Functions

func AutoConfigMapName added in v0.2.0

func AutoConfigMapName(cr *apiv1.PerconaServerMySQL) string

func CanonicalVariableName added in v1.3.0

func CanonicalVariableName(key string) string

CanonicalVariableName strips the loose prefix.

func ConfigMapName

func ConfigMapName(cr *apiv1.PerconaServerMySQL) string

func DataVolumeSize added in v1.3.0

func DataVolumeSize(cr *apiv1.PerconaServerMySQL) int64

DataVolumeSize returns the size the cr asks for the MySQL data volume, or zero when nothing in the spec bounds it.

func EffectiveResource added in v1.3.0

func EffectiveResource(res corev1.ResourceRequirements, name corev1.ResourceName) *resource.Quantity

EffectiveResource returns the limit, else the request, else nil.

func FQDN added in v0.2.0

func FQDN(cr *apiv1.PerconaServerMySQL, idx int) string

func FormatConfigValue added in v1.3.0

func FormatConfigValue(value string) string

func GetAppliedCRVersion added in v1.3.0

func GetAppliedCRVersion(ctx context.Context, cl client.Reader, cr *apiv1.PerconaServerMySQL) (string, error)

GetAppliedCRVersion returns the version of the CR that is currently applied to the StatefulSet. It returns the current CR_VERSION env variable value from the StatefulSet container spec. If the StatefulSet has not yet rolled out, it returns ErrRolloutInProgress.

func GetAutoConfigParams added in v1.3.0

func GetAutoConfigParams(cr *apiv1.PerconaServerMySQL, version string, cpu, memory *resource.Quantity, storage int64) (string, error)

GetAutoConfigParams derives a full set of mysqld parameters from the pod's CPU/memory allocation, the workload profile, the version and the topology.

func GetAutoTuneParams added in v0.2.0

func GetAutoTuneParams(cr *apiv1.PerconaServerMySQL, q *resource.Quantity) (string, error)

GetAutoTuneParams derives innodb_buffer_pool_size, innodb_buffer_pool_chunk_size and max_connections from the given memory quantity.

func GetConfig added in v1.3.0

func GetConfig(
	ctx context.Context,
	cl client.Reader,
	cr *apiv1.PerconaServerMySQL,
	autoConf string,
) (config.Section, error)

GetConfig merges the configuration mysqld runs with, in order: autoConf, the user configuration and the user secret.

func GetLastAppliedConfig added in v1.3.0

func GetLastAppliedConfig(
	sts *appsv1.StatefulSet,
) (config.Section, error)

func GetPod added in v0.12.0

func GetPod(ctx context.Context, cl client.Reader, cr *apiv1.PerconaServerMySQL, idx int) (*corev1.Pod, error)

func GetReadyPod added in v0.12.0

func GetReadyPod(ctx context.Context, cl client.Reader, cr *apiv1.PerconaServerMySQL) (*corev1.Pod, error)

func HasUserConfig added in v1.3.0

func HasUserConfig(
	ctx context.Context,
	cl client.Reader,
	cr *apiv1.PerconaServerMySQL,
) (bool, error)

HasUserConfig reports whether the user supplied a MySQL configuration of their own, through mysql.configuration or by creating the ConfigMap or Secret directly.

func HeadlessService

func HeadlessService(cr *apiv1.PerconaServerMySQL) *corev1.Service

func IsLooseVariable added in v1.3.0

func IsLooseVariable(key string) bool

IsLooseVariable reports whether key carries the loose prefix.

func Labels added in v0.12.0

func Labels(cr *apiv1.PerconaServerMySQL) map[string]string

func MatchLabels

func MatchLabels(cr *apiv1.PerconaServerMySQL) map[string]string

func MatchesConfigValue added in v1.3.0

func MatchesConfigValue(current, formatted string) bool

MatchesConfigValue reports whether the raw value mysqld currently holds is the one the already formatted value asks for.

func Name

func PodFQDN added in v0.8.0

func PodFQDN(cr *apiv1.PerconaServerMySQL, pod *corev1.Pod) string

func PodName added in v0.2.0

func PodName(cr *apiv1.PerconaServerMySQL, idx int) string

func PodService

func PodService(cr *apiv1.PerconaServerMySQL, t corev1.ServiceType, podName string) *corev1.Service

func PrimaryService

func PrimaryService(cr *apiv1.PerconaServerMySQL) *corev1.Service

PrimaryService constructs a service which exposes the pods that has the primary label. For now this service should be available only for group replication.

func PrimaryServiceName

func PrimaryServiceName(cr *apiv1.PerconaServerMySQL) string

func ProxyService added in v0.6.0

func ProxyService(cr *apiv1.PerconaServerMySQL) *corev1.Service

func ProxyServiceName added in v0.6.0

func ProxyServiceName(cr *apiv1.PerconaServerMySQL) string

func QuoteLiteral added in v1.3.0

func QuoteLiteral(value string) string

QuoteLiteral renders value as a single SQL string literal. Quotes are doubled rather than backslash-escaped so it holds under NO_BACKSLASH_ESCAPES too.

func ServiceFQDN added in v1.2.0

func ServiceFQDN(cr *apiv1.PerconaServerMySQL) string

func ServiceName

func ServiceName(cr *apiv1.PerconaServerMySQL) string

func StatefulSet

func StatefulSet(cr *apiv1.PerconaServerMySQL, initImage, configHash, tlsHash, logCollectorHash string, secret *corev1.Secret) *appsv1.StatefulSet

func UnreadyService

func UnreadyService(cr *apiv1.PerconaServerMySQL) *corev1.Service

func UnreadyServiceName

func UnreadyServiceName(cr *apiv1.PerconaServerMySQL) string

Types

type Component added in v0.12.0

type Component apiv1.PerconaServerMySQL

func (*Component) Labels added in v0.12.0

func (c *Component) Labels() map[string]string

func (*Component) MatchLabels added in v0.12.0

func (c *Component) MatchLabels() map[string]string

func (*Component) Name added in v0.12.0

func (c *Component) Name() string

func (*Component) Object added in v0.12.0

func (c *Component) Object(ctx context.Context, cl client.Client) (client.Object, error)

func (*Component) PerconaServerMySQL added in v0.12.0

func (c *Component) PerconaServerMySQL() *apiv1.PerconaServerMySQL

func (*Component) PodSpec added in v0.12.0

func (c *Component) PodSpec() *apiv1.PodSpec

type Configurable added in v0.6.0

type Configurable apiv1.PerconaServerMySQL

func (*Configurable) ExecuteConfigurationTemplate added in v0.6.0

func (c *Configurable) ExecuteConfigurationTemplate(input string, memory *resource.Quantity) (string, error)

func (*Configurable) GetConfigMapKey added in v0.6.0

func (c *Configurable) GetConfigMapKey() string

func (*Configurable) GetConfigMapName added in v0.6.0

func (c *Configurable) GetConfigMapName() string

func (*Configurable) GetConfiguration added in v0.6.0

func (c *Configurable) GetConfiguration() string

func (*Configurable) GetResources added in v0.6.0

func (c *Configurable) GetResources() corev1.ResourceRequirements

type Exposer added in v0.2.0

type Exposer apiv1.PerconaServerMySQL

func (*Exposer) Exposed added in v0.2.0

func (e *Exposer) Exposed() bool

func (*Exposer) MatchLabels added in v0.12.0

func (e *Exposer) MatchLabels() map[string]string

func (*Exposer) Name added in v0.2.0

func (e *Exposer) Name(index string) string

func (*Exposer) SaveOldMeta added in v0.4.0

func (e *Exposer) SaveOldMeta() bool

func (*Exposer) Service added in v0.2.0

func (e *Exposer) Service(name string) *corev1.Service

func (*Exposer) Size added in v0.2.0

func (e *Exposer) Size() int32

type User

type User struct {
	Username apiv1.SystemUser
	Password string
	Hosts    []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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