builder

package
v25.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageVolume            = "storage"
	MariadbStorageMountPath  = "/var/lib/mysql"
	MaxscaleStorageMountPath = "/var/lib/maxscale"
	StorageVolumeRole        = "storage"

	MariadbConfigVolume     = "mariadb-config"
	MariadbConfigMountPath  = "/etc/mysql/mariadb.conf.d"
	ConfigVolume            = "config"
	ConfigMountPath         = "/etc/mysql/conf.d"
	MaxscaleConfigMountPath = "/etc/config"
	ConfigVolumeRole        = "config"

	AgentAuthVolume      = "agent-auth"
	AgentAuthVolumeMount = "/var/run/secrets/mariadb-operator/agent"

	RunVolume            = "run"
	MaxScaleRunMountPath = "/var/run/maxscale"

	LogVolume            = "log"
	MaxScaleLogMountPath = "/var/log/maxscale"

	CacheVolume            = "cache"
	MaxScaleCacheMountPath = "/var/cache/maxscale"

	InitVolume        = "init"
	InitConfigPath    = "/init"
	InitLibKey        = "lib.sh"
	InitEntrypointKey = "entrypoint.sh"

	ServiceAccountVolume    = "serviceaccount"
	ServiceAccountMountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
)
View Source
const (
	MetricsPortName = "metrics"
)

Variables

View Source
var (
	MariadbContainerName = "mariadb"
	MariadbPortName      = "mariadb"

	MaxScaleContainerName = "maxscale"
	MaxScaleAdminPortName = "admin"

	InitContainerName  = "init"
	AgentContainerName = "agent"
)

Functions

func MariaDBPort

func MariaDBPort(svc *corev1.Service) (*corev1.ServicePort, error)

func ValidateServicePorts

func ValidateServicePorts(ports []corev1.ServicePort) error

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(scheme *runtime.Scheme, env *environment.OperatorEnv, discovery *discovery.Discovery) *Builder

func (*Builder) BuildBackupCronJob

func (b *Builder) BuildBackupCronJob(key types.NamespacedName, backup *mariadbv1alpha1.Backup,
	mariadb interfaces.MariaDBObject) (*batchv1.CronJob, error)

func (*Builder) BuildBackupJob

func (b *Builder) BuildBackupJob(key types.NamespacedName, backup *mariadbv1alpha1.Backup,
	mariadb interfaces.MariaDBObject) (*batchv1.Job, error)

func (*Builder) BuildCertificate

func (b *Builder) BuildCertificate(certOpts ...CertOpt) (*certmanagerv1.Certificate, error)

func (*Builder) BuildClusterRoleBinding

func (b *Builder) BuildClusterRoleBinding(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB, sa *corev1.ServiceAccount,
	roleRef rbacv1.RoleRef) (*rbacv1.ClusterRoleBinding, error)

func (*Builder) BuildConfigMap

func (b *Builder) BuildConfigMap(opts ConfigMapOpts, owner metav1.Object) (*corev1.ConfigMap, error)

func (*Builder) BuildConnection

func (b *Builder) BuildConnection(opts ConnectionOpts, owner metav1.Object) (*mariadbv1alpha1.Connection, error)

func (*Builder) BuildDatabase

func (b *Builder) BuildDatabase(key types.NamespacedName, owner metav1.Object, opts DatabaseOpts) (*mariadbv1alpha1.Database, error)

func (*Builder) BuildEndpointSlice

func (b *Builder) BuildEndpointSlice(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB,
	addressType discoveryv1.AddressType, endpoints []discoveryv1.Endpoint, ports []discoveryv1.EndpointPort,
	serviceName string) (*discoveryv1.EndpointSlice, error)

func (*Builder) BuildExporterDeployment

func (b *Builder) BuildExporterDeployment(mariadb *mariadbv1alpha1.MariaDB,
	podAnnotations map[string]string) (*appsv1.Deployment, error)

func (*Builder) BuildGaleraInitJob

func (b *Builder) BuildGaleraInitJob(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB) (*batchv1.Job, error)

func (*Builder) BuildGaleraRecoveryJob

func (b *Builder) BuildGaleraRecoveryJob(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB,
	pod *corev1.Pod) (*batchv1.Job, error)

func (*Builder) BuildGrant

func (b *Builder) BuildGrant(key types.NamespacedName, owner metav1.Object, opts GrantOpts) (*mariadbv1alpha1.Grant, error)

func (*Builder) BuildMariadbStatefulSet

func (b *Builder) BuildMariadbStatefulSet(mariadb *mariadbv1alpha1.MariaDB, key types.NamespacedName,
	podAnnotations map[string]string) (*appsv1.StatefulSet, error)

func (*Builder) BuildMaxScaleExporterDeployment

func (b *Builder) BuildMaxScaleExporterDeployment(mxs *mariadbv1alpha1.MaxScale,
	podAnnotations map[string]string) (*appsv1.Deployment, error)

func (*Builder) BuildMaxScaleServiceMonitor

func (b *Builder) BuildMaxScaleServiceMonitor(mxs *mariadbv1alpha1.MaxScale) (*monitoringv1.ServiceMonitor, error)

func (*Builder) BuildMaxscaleStatefulSet

func (b *Builder) BuildMaxscaleStatefulSet(maxscale *mariadbv1alpha1.MaxScale, key types.NamespacedName,
	podAnnotations map[string]string) (*appsv1.StatefulSet, error)

func (*Builder) BuildPhysicalBackupJob

func (b *Builder) BuildPhysicalBackupJob(key types.NamespacedName, backup *mariadbv1alpha1.PhysicalBackup,
	mariadb *mariadbv1alpha1.MariaDB, pod *corev1.Pod, backupFile string) (*batchv1.Job, error)

func (*Builder) BuildPhysicalBackupRestoreJob

func (b *Builder) BuildPhysicalBackupRestoreJob(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB,
	podIndex *int, restoreOpts ...PhysicalBackupRestoreOpt) (*batchv1.Job, error)

func (*Builder) BuildPodDisruptionBudget

func (b *Builder) BuildPodDisruptionBudget(opts PodDisruptionBudgetOpts, owner metav1.Object) (*policyv1.PodDisruptionBudget, error)

func (*Builder) BuildReplicaRecoveryPhysicalBackup added in v25.10.0

func (b *Builder) BuildReplicaRecoveryPhysicalBackup(key types.NamespacedName, tpl *mariadbv1alpha1.PhysicalBackup,
	mariadb *mariadbv1alpha1.MariaDB) (*mariadbv1alpha1.PhysicalBackup, error)

func (*Builder) BuildRestore

func (b *Builder) BuildRestore(mariadb *mariadbv1alpha1.MariaDB, key types.NamespacedName) (*mariadbv1alpha1.Restore, error)

func (*Builder) BuildRestoreJob

func (b *Builder) BuildRestoreJob(key types.NamespacedName, restore *mariadbv1alpha1.Restore,
	mariadb interfaces.MariaDBObject) (*batchv1.Job, error)

func (*Builder) BuildRole

func (b *Builder) BuildRole(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB, rules []rbacv1.PolicyRule) (*rbacv1.Role, error)

func (*Builder) BuildRoleBinding

func (b *Builder) BuildRoleBinding(key types.NamespacedName, mariadb *mariadbv1alpha1.MariaDB, sa *corev1.ServiceAccount,
	roleRef rbacv1.RoleRef) (*rbacv1.RoleBinding, error)

func (*Builder) BuildSecret

func (b *Builder) BuildSecret(opts SecretOpts, owner metav1.Object) (*corev1.Secret, error)

func (*Builder) BuildService

func (b *Builder) BuildService(key types.NamespacedName, owner metav1.Object, opts ServiceOpts) (*corev1.Service, error)

func (*Builder) BuildServiceAccount

func (b *Builder) BuildServiceAccount(key types.NamespacedName, owner metav1.Object,
	meta *mariadbv1alpha1.Metadata) (*corev1.ServiceAccount, error)

func (*Builder) BuildServiceMonitor

func (b *Builder) BuildServiceMonitor(mariadb *mariadbv1alpha1.MariaDB) (*monitoringv1.ServiceMonitor, error)

func (*Builder) BuildSqlCronJob

func (b *Builder) BuildSqlCronJob(key types.NamespacedName, sqlJob *mariadbv1alpha1.SqlJob,
	mariadb interfaces.MariaDBObject) (*batchv1.CronJob, error)

func (*Builder) BuildSqlJob

func (b *Builder) BuildSqlJob(key types.NamespacedName, sqlJob *mariadbv1alpha1.SqlJob,
	mariadb interfaces.MariaDBObject) (*batchv1.Job, error)

func (*Builder) BuildUser

func (b *Builder) BuildUser(key types.NamespacedName, owner metav1.Object, opts UserOpts) (*mariadbv1alpha1.User, error)

type CertOpt

type CertOpt func(*CertOpts)

func WithDNSnames

func WithDNSnames(names []string) CertOpt

func WithIssuerRef

func WithIssuerRef(issuerRef cmmeta.ObjectReference) CertOpt

func WithKey

func WithKey(key types.NamespacedName) CertOpt

func WithLifetime

func WithLifetime(lifetime time.Duration) CertOpt

func WithOwner

func WithOwner(owner metav1.Object) CertOpt

func WithRenewBeforePercentage

func WithRenewBeforePercentage(percentage int32) CertOpt

func WithUsages

func WithUsages(usages ...certmanagerv1.KeyUsage) CertOpt

type CertOpts

type CertOpts struct {
	Key                   *types.NamespacedName
	Owner                 metav1.Object
	DNSNames              []string
	Lifetime              *time.Duration
	RenewBeforePercentage *int32
	Usages                []certmanagerv1.KeyUsage
	IssuerRef             *cmmeta.ObjectReference
}

type ConfigMapOpts

type ConfigMapOpts struct {
	Metadata *mariadbv1alpha1.Metadata
	Key      types.NamespacedName
	Data     map[string]string
}

type ConnectionOpts

type ConnectionOpts struct {
	Metadata             *mariadbv1alpha1.Metadata
	MariaDB              *mariadbv1alpha1.MariaDB
	ExternalMariaDB      *mariadbv1alpha1.ExternalMariaDB
	MaxScale             *mariadbv1alpha1.MaxScale
	Key                  types.NamespacedName
	Username             string
	PasswordSecretKeyRef *mariadbv1alpha1.SecretKeySelector
	Database             *string
	Template             *mariadbv1alpha1.ConnectionTemplate
}

type DatabaseOpts

type DatabaseOpts struct {
	Name       string
	Metadata   *mariadbv1alpha1.Metadata
	MariaDBRef mariadbv1alpha1.MariaDBRef
}

type GrantOpts

type GrantOpts struct {
	Privileges    []string
	Database      string
	Table         string
	Username      string
	Host          string
	GrantOption   bool
	CleanupPolicy *mariadbv1alpha1.CleanupPolicy
	Metadata      *mariadbv1alpha1.Metadata
	MariaDBRef    mariadbv1alpha1.MariaDBRef
}

type PVCOption

type PVCOption func(*corev1.PersistentVolumeClaimSpec)

func WithVolumeSnapshotDataSource

func WithVolumeSnapshotDataSource(snapshotName string) PVCOption

type PhysicalBackupRestoreOpt added in v25.10.0

type PhysicalBackupRestoreOpt func(*PhysicalBackupRestoreOpts) error

func WithBootstrapFrom added in v25.10.0

func WithBootstrapFrom(bootstrapFrom *mariadbv1alpha1.BootstrapFrom) PhysicalBackupRestoreOpt

func WithPhysicalBackup added in v25.10.0

func WithPhysicalBackup(pb *mariadbv1alpha1.PhysicalBackup, targetRecoveryTime time.Time,
	restoreJob *mariadbv1alpha1.Job, restoreCommandOpts ...command.MariaDBBackupRestoreOpt) PhysicalBackupRestoreOpt

func WithReplicaRecovery added in v25.10.0

func WithReplicaRecovery(podToRecover *corev1.Pod) PhysicalBackupRestoreOpt

type PhysicalBackupRestoreOpts added in v25.10.0

type PhysicalBackupRestoreOpts struct {
	TargetRecoveryTime *time.Time
	Volume             *mariadbv1alpha1.StorageVolumeSource
	S3                 *mariadbv1alpha1.S3
	RestoreJob         *mariadbv1alpha1.Job
	RestoreCommandOpts []command.MariaDBBackupRestoreOpt
	MariaDBLabels      *bool
	Affinity           *bool
	NodeSelector       map[string]string
}

type PodDisruptionBudgetOpts

type PodDisruptionBudgetOpts struct {
	Metadata       *mariadbv1alpha1.Metadata
	Key            types.NamespacedName
	MinAvailable   *intstr.IntOrString
	MaxUnavailable *intstr.IntOrString
	SelectorLabels map[string]string
}

type SecretOpts

type SecretOpts struct {
	Metadata []*mariadbv1alpha1.Metadata
	Key      types.NamespacedName
	Data     map[string][]byte
}

type ServiceOpts

type ServiceOpts struct {
	mariadbv1alpha1.ServiceTemplate
	SelectorLabels        map[string]string
	ExcludeSelectorLabels bool
	Ports                 []corev1.ServicePort
	Headless              bool
	ExtraMeta             *mariadbv1alpha1.Metadata
}

type UserOpts

type UserOpts struct {
	Name                     string
	Host                     string
	PasswordSecretKeyRef     *mariadbv1alpha1.SecretKeySelector
	PasswordHashSecretKeyRef *mariadbv1alpha1.SecretKeySelector
	PasswordPlugin           *mariadbv1alpha1.PasswordPlugin
	MaxUserConnections       int32
	CleanupPolicy            *mariadbv1alpha1.CleanupPolicy
	Metadata                 *mariadbv1alpha1.Metadata
	MariaDBRef               mariadbv1alpha1.MariaDBRef
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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