Documentation ¶
Index ¶
- Constants
- func AliasFromPod(pod *corev1.Pod) topodatapb.TabletAlias
- func BackupPodName(clusterName, keyspaceName string, keyRange planetscalev2.VitessKeyRange, ...) string
- func InitialBackupPodName(clusterName, keyspaceName string, keyRange planetscalev2.VitessKeyRange) string
- func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage string) *corev1.Pod
- func NewPVC(key client.ObjectKey, spec *Spec) *corev1.PersistentVolumeClaim
- func NewPod(key client.ObjectKey, spec *Spec) *corev1.Pod
- func NewService(key client.ObjectKey, labels map[string]string) *corev1.Service
- func PodName(clusterName string, tabletAlias topodatapb.TabletAlias) string
- func ServiceName(clusterName string) string
- func UID(cellName, keyspaceName string, shardKeyRange planetscalev2.VitessKeyRange, ...) uint32
- func UIDWithPoolName(cellName, keyspaceName string, shardKeyRange planetscalev2.VitessKeyRange, ...) uint32
- func UpdatePVCInPlace(obj *corev1.PersistentVolumeClaim, spec *Spec)
- func UpdatePod(obj *corev1.Pod, spec *Spec)
- func UpdatePodInPlace(obj *corev1.Pod, spec *Spec)
- func UpdateService(obj *corev1.Service, labels map[string]string)
- type BackupSpec
- type Spec
Constants ¶
const (
MysqldContainerName = "mysqld"
)
Variables ¶
This section is empty.
Functions ¶
func AliasFromPod ¶
func AliasFromPod(pod *corev1.Pod) topodatapb.TabletAlias
AliasFromPod returns a TabletAlias corresponding to a vttablet Pod.
func BackupPodName ¶
func BackupPodName(clusterName, keyspaceName string, keyRange planetscalev2.VitessKeyRange, backupLocationName string, lastBackupTime time.Time) string
BackupPodName returns the name of the Pod for a periodic vtbackup job. The Pod name incorporates the time of the latest backup so a stale backup job (started a long time ago) will never be mistaken for a current one.
func InitialBackupPodName ¶
func InitialBackupPodName(clusterName, keyspaceName string, keyRange planetscalev2.VitessKeyRange) string
InitialBackupPodName returns the name of the Pod for an initial vtbackup job.
func NewBackupPod ¶
NewBackupPod creates a new vtbackup Pod, which is like a special kind of minimal tablet used to run backups as a batch process.
func NewPVC ¶
func NewPVC(key client.ObjectKey, spec *Spec) *corev1.PersistentVolumeClaim
NewPVC creates a new vttablet PVC from a Spec.
func NewService ¶
NewService creates a new Service object for vtgate.
func PodName ¶
func PodName(clusterName string, tabletAlias topodatapb.TabletAlias) string
PodName returns the name of the Pod for a given vttablet.
func ServiceName ¶
ServiceName returns the name of the vttablet Service for a cluster.
func UID ¶
func UID(cellName, keyspaceName string, shardKeyRange planetscalev2.VitessKeyRange, tabletPoolType planetscalev2.VitessTabletPoolType, tabletIndex uint32) uint32
UID deterministically generates a 32-bit unsigned integer that should uniquely identify a given tablet within a Vitess cluster.
The tablet's identity is defined as the tuple (cell,keyspace,shard,pool,index). Any such tuple must map to only one uint32 value (the same tuple always results in the same integer), and there must be a negligible probability of accidental collisions within a given Vitess cluster.
The approach we use here is to take the first 32 bits of a hash of those tuple elements, which is essentially how YouTube did it. If we assume the first 32 bits of the hash fall in a uniform distribution, the probability of at least one collision in a cluster with 1000 total tablets is about 0.0001. That means we should expect to have one cluster experience a collision by the time we reach 10,000 clusters if each cluster has 1000 tablets. This should provide enough lead time to develop a smarter way to handle tablet identity and MySQL server IDs in Vitess itself.
WARNING: DO NOT change the behavior of this function, as that may result in
the deletion and recreation of all tablets.
func UIDWithPoolName ¶
func UIDWithPoolName(cellName, keyspaceName string, shardKeyRange planetscalev2.VitessKeyRange, tabletPoolType planetscalev2.VitessTabletPoolType, tabletName uint32, poolName string) uint32
UIDWithPoolName function generates a 32-bit unsigned integer similar to the UID function above.
However, it additionally takes the poolName as an input. This allows the generation of a unique UID for a tablet that belongs to a different pool but shares other common attributes.
To preserve the existing UID, it is recommended to use the UID function instead of this function when the poolName is set to its default value of an empty string.
func UpdatePVCInPlace ¶
func UpdatePVCInPlace(obj *corev1.PersistentVolumeClaim, spec *Spec)
UpdatePVCInPlace updates an existing vttablet PVC in-place.
func UpdatePod ¶
UpdatePod updates all parts of a vttablet Pod to match the desired state, including parts that are immutable. If anything actually changes, the Pod must be deleted and recreated as part of a rolling update in order to converge to the desired state.
func UpdatePodInPlace ¶
UpdatePodInPlace updates only the parts of a vttablet Pod that can be changed immediately by an in-place update.
Types ¶
type BackupSpec ¶
type BackupSpec struct { // TabletSpec is the spec for a vttablet Pod. A backup Pod is a special kind // of tablet, so it needs much of the same configuration. TabletSpec *Spec // InitialBackup means don't try to restore from backup, because there // aren't any. Instead, bootstrap the shard with a backup of an empty // database. InitialBackup bool // MinBackupInterval is the minimum spacing between backups. // A new backup will only be taken if it's been at least this long since the // most recent backup. MinBackupInterval time.Duration // MinRetentionTime is the minimum time to retain each backup. // Each backup will be kept until it is at least this old. // A retention time of 0 means never delete any backups at all. MinRetentionTime time.Duration // MinRetentionCount is the minimum number of backups to retain. // Even if a backup is past the MinRetentionTime, it will not be deleted if // doing so would take the total number of backups below MinRetentionCount. MinRetentionCount int }
BackupSpec is the spec for a Backup Pod.
type Spec ¶
type Spec struct { Alias topodatapb.TabletAlias AliasStr string Type planetscalev2.VitessTabletPoolType Zone string Labels map[string]string Images planetscalev2.VitessKeyspaceImages ImagePullPolicies planetscalev2.VitessImagePullPolicies ImagePullSecrets []corev1.LocalObjectReference Index int32 KeyRange planetscalev2.VitessKeyRange KeyspaceName string DatabaseName string Vttablet *planetscalev2.VttabletSpec Mysqld *planetscalev2.MysqldSpec MysqldExporter *planetscalev2.MysqldExporterSpec ExternalDatastore *planetscalev2.ExternalDatastore DataVolumePVCSpec *corev1.PersistentVolumeClaimSpec DataVolumePVCName string GlobalLockserver planetscalev2.VitessLockserverParams DatabaseInitScriptSecret planetscalev2.SecretSource Annotations map[string]string ExtraLabels map[string]string BackupLocation *planetscalev2.VitessBackupLocation BackupEngine planetscalev2.VitessBackupEngine Affinity *corev1.Affinity ExtraEnv []corev1.EnvVar ExtraVolumes []corev1.Volume ExtraVolumeMounts []corev1.VolumeMount InitContainers []corev1.Container SidecarContainers []corev1.Container Tolerations []corev1.Toleration TopologySpreadConstraints []corev1.TopologySpreadConstraint }
Spec specifies all the internal parameters needed to deploy a vttablet instance.