Documentation ¶
Index ¶
- Constants
- func AddConfigMapDigestSuffix(cm *corev1.ConfigMap) error
- func CombineAnnotations(a, b map[string]string) map[string]string
- func FindConfigMapVolume(podSpec *corev1.PodSpec, pred func(string) bool) string
- func GetLastAppliedConfig(set *apps.StatefulSet) (*apps.StatefulSetSpec, *corev1.PodSpec, error)
- func MapContainers(podSpec *corev1.PodSpec) map[string]corev1.Container
- func MarshalTOML(v interface{}) ([]byte, error)
- func MemberPodName(tcName string, ordinal int32, memberType v1alpha1.MemberType) string
- func NeedForceUpgrade(tc *v1alpha1.TikvCluster) bool
- func NewPDMemberManager(pdControl pdapi.PDControlInterface, ...) manager.Manager
- func NewTiKVMemberManager(pdControl pdapi.PDControlInterface, ...) manager.Manager
- func PdPodName(tcName string, ordinal int32) string
- func RenderPDStartScript(model *PDStartScriptModel) (string, error)
- func RenderPumpStartScript(model *PumpStartScriptModel) (string, error)
- func RenderTiDBInitInitStartScript(model *TiDBInitInitStartScriptModel) (string, error)
- func RenderTiDBInitStartScript(model *TiDBInitStartScriptModel) (string, error)
- func RenderTiDBStartScript(model *TidbStartScriptModel) (string, error)
- func RenderTiKVStartScript(model *TiKVStartScriptModel) (string, error)
- func SetStatefulSetLastAppliedConfigAnnotation(set *apps.StatefulSet) error
- func Sha256Sum(v interface{}) (string, error)
- func TikvPodName(tcName string, ordinal int32) string
- func UnmarshalTOML(b []byte, obj interface{}) error
- type Failover
- type FakeDiscoveryManager
- type FakeOrphanPodsCleaner
- type FakePDMemberManager
- type FakeTiKVMemberManager
- type OrphanPodsCleaner
- type PDDiscoveryManager
- type PDStartScriptModel
- type PumpStartScriptModel
- type Scaler
- type SvcConfig
- type TiDBInitInitStartScriptModel
- type TiDBInitStartScriptModel
- type TiKVStartScriptModel
- type TidbStartScriptModel
- type Upgrader
Constants ¶
const ( // EvictLeaderBeginTime is the key of evict Leader begin time EvictLeaderBeginTime = "evictLeaderBeginTime" // EvictLeaderTimeout is the timeout limit of evict leader EvictLeaderTimeout = 3 * time.Minute )
const ( // LastAppliedConfigAnnotation is annotation key of last applied configuration LastAppliedConfigAnnotation = "tikv.org/last-applied-configuration" // ImagePullBackOff is the pod state of image pull failed ImagePullBackOff = "ImagePullBackOff" // ErrImagePull is the pod state of image pull failed ErrImagePull = "ErrImagePull" )
Variables ¶
This section is empty.
Functions ¶
func CombineAnnotations ¶
CombineAnnotations merges two annotations maps
func FindConfigMapVolume ¶
FindConfigMapVolume returns the configmap which's name matches the predicate in a PodSpec, empty indicates not found
func GetLastAppliedConfig ¶
func GetLastAppliedConfig(set *apps.StatefulSet) (*apps.StatefulSetSpec, *corev1.PodSpec, error)
GetLastAppliedConfig get last applied config info from Statefulset's annotation and the podTemplate's annotation
func MapContainers ¶
MapContainers index containers of Pod by container name in favor of looking up
func MarshalTOML ¶
MarshalTOML is a template function that try to marshal a go value to toml
func MemberPodName ¶
func MemberPodName(tcName string, ordinal int32, memberType v1alpha1.MemberType) string
func NeedForceUpgrade ¶
func NeedForceUpgrade(tc *v1alpha1.TikvCluster) bool
NeedForceUpgrade check if force upgrade is necessary
func NewPDMemberManager ¶
func NewPDMemberManager(pdControl pdapi.PDControlInterface, setControl controller.StatefulSetControlInterface, svcControl controller.ServiceControlInterface, podControl controller.PodControlInterface, typedControl controller.TypedControlInterface, setLister v1.StatefulSetLister, svcLister corelisters.ServiceLister, podLister corelisters.PodLister, epsLister corelisters.EndpointsLister, pvcLister corelisters.PersistentVolumeClaimLister, pdScaler Scaler, pdUpgrader Upgrader, autoFailover bool, pdFailover Failover) manager.Manager
NewPDMemberManager returns a *pdMemberManager
func NewTiKVMemberManager ¶
func NewTiKVMemberManager( pdControl pdapi.PDControlInterface, setControl controller.StatefulSetControlInterface, svcControl controller.ServiceControlInterface, typedControl controller.TypedControlInterface, setLister v1.StatefulSetLister, svcLister corelisters.ServiceLister, podLister corelisters.PodLister, nodeLister corelisters.NodeLister, autoFailover bool, tikvFailover Failover, tikvScaler Scaler, tikvUpgrader Upgrader) manager.Manager
NewTiKVMemberManager returns a *tikvMemberManager
func RenderPDStartScript ¶
func RenderPDStartScript(model *PDStartScriptModel) (string, error)
func RenderPumpStartScript ¶
func RenderPumpStartScript(model *PumpStartScriptModel) (string, error)
func RenderTiDBInitInitStartScript ¶
func RenderTiDBInitInitStartScript(model *TiDBInitInitStartScriptModel) (string, error)
func RenderTiDBInitStartScript ¶
func RenderTiDBInitStartScript(model *TiDBInitStartScriptModel) (string, error)
func RenderTiDBStartScript ¶
func RenderTiDBStartScript(model *TidbStartScriptModel) (string, error)
func RenderTiKVStartScript ¶
func RenderTiKVStartScript(model *TiKVStartScriptModel) (string, error)
func SetStatefulSetLastAppliedConfigAnnotation ¶
func SetStatefulSetLastAppliedConfigAnnotation(set *apps.StatefulSet) error
SetStatefulSetLastAppliedConfigAnnotation set last applied config to Statefulset's annotation
func TikvPodName ¶
func UnmarshalTOML ¶
Types ¶
type Failover ¶
type Failover interface { Failover(*v1alpha1.TikvCluster) error Recover(*v1alpha1.TikvCluster) }
Failover implements the logic for pd/tikv/tidb's failover and recovery.
func NewFakePDFailover ¶
func NewFakePDFailover() Failover
NewFakePDFailover returns a fake Failover
func NewFakeTiKVFailover ¶
func NewFakeTiKVFailover() Failover
NewFakeTiKVFailover returns a fake Failover
func NewPDFailover ¶
func NewPDFailover(cli versioned.Interface, pdControl pdapi.PDControlInterface, pdFailoverPeriod time.Duration, podLister corelisters.PodLister, podControl controller.PodControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvcControl controller.PVCControlInterface, pvLister corelisters.PersistentVolumeLister, recorder record.EventRecorder) Failover
NewPDFailover returns a pd Failover
func NewTiKVFailover ¶
func NewTiKVFailover(tikvFailoverPeriod time.Duration, recorder record.EventRecorder) Failover
NewTiKVFailover returns a tikv Failover
type FakeDiscoveryManager ¶
type FakeDiscoveryManager struct {
// contains filtered or unexported fields
}
func NewFakeDiscoveryManger ¶
func NewFakeDiscoveryManger() *FakeDiscoveryManager
func (*FakeDiscoveryManager) Reconcile ¶
func (fdm *FakeDiscoveryManager) Reconcile(_ *v1alpha1.TikvCluster) error
func (*FakeDiscoveryManager) SetReconcileError ¶
func (fdm *FakeDiscoveryManager) SetReconcileError(err error)
type FakeOrphanPodsCleaner ¶
type FakeOrphanPodsCleaner struct {
// contains filtered or unexported fields
}
func NewFakeOrphanPodsCleaner ¶
func NewFakeOrphanPodsCleaner() *FakeOrphanPodsCleaner
NewFakeOrphanPodsCleaner returns a fake orphan pods cleaner
func (*FakeOrphanPodsCleaner) Clean ¶
func (fpc *FakeOrphanPodsCleaner) Clean(_ *v1alpha1.TikvCluster) (map[string]string, error)
func (*FakeOrphanPodsCleaner) SetnOrphanPodCleanerError ¶
func (fpc *FakeOrphanPodsCleaner) SetnOrphanPodCleanerError(err error)
type FakePDMemberManager ¶
type FakePDMemberManager struct {
// contains filtered or unexported fields
}
func NewFakePDMemberManager ¶
func NewFakePDMemberManager() *FakePDMemberManager
func (*FakePDMemberManager) SetSyncError ¶
func (fpmm *FakePDMemberManager) SetSyncError(err error)
func (*FakePDMemberManager) Sync ¶
func (fpmm *FakePDMemberManager) Sync(tc *v1alpha1.TikvCluster) error
type FakeTiKVMemberManager ¶
type FakeTiKVMemberManager struct {
// contains filtered or unexported fields
}
func NewFakeTiKVMemberManager ¶
func NewFakeTiKVMemberManager() *FakeTiKVMemberManager
func (*FakeTiKVMemberManager) SetSyncError ¶
func (ftmm *FakeTiKVMemberManager) SetSyncError(err error)
func (*FakeTiKVMemberManager) Sync ¶
func (ftmm *FakeTiKVMemberManager) Sync(tc *v1alpha1.TikvCluster) error
type OrphanPodsCleaner ¶
type OrphanPodsCleaner interface {
Clean(*v1alpha1.TikvCluster) (map[string]string, error)
}
OrphanPodsCleaner implements the logic for cleaning the orphan pods(has no pvc)
In scaling out and failover, we will try to delete the old PVC to prevent it from being used by the new pod. However, the PVC might not be deleted immediately in the apiserver because of finalizers (e.g. kubernetes.io/pvc-protection) and the statefulset controller may not have received PVC delete event when it tries to create the new replica and the new pod will be pending forever because no PVC to use. We need to clean these orphan pods and let the statefulset controller to create PVC(s) for them.
func NewOrphanPodsCleaner ¶
func NewOrphanPodsCleaner(podLister corelisters.PodLister, podControl controller.PodControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, kubeCli kubernetes.Interface) OrphanPodsCleaner
NewOrphanPodsCleaner returns a OrphanPodsCleaner
type PDDiscoveryManager ¶
type PDDiscoveryManager interface {
Reconcile(tc *v1alpha1.TikvCluster) error
}
func NewPDDiscoveryManager ¶
func NewPDDiscoveryManager(typedControl controller.TypedControlInterface) PDDiscoveryManager
type PDStartScriptModel ¶
type PDStartScriptModel struct {
Scheme string
}
type PumpStartScriptModel ¶
type Scaler ¶
type Scaler interface { // Scale scales the cluster. It does nothing if scaling is not needed. Scale(tc *v1alpha1.TikvCluster, actual *apps.StatefulSet, desired *apps.StatefulSet) error // ScaleOut scales out the cluster ScaleOut(tc *v1alpha1.TikvCluster, actual *apps.StatefulSet, desired *apps.StatefulSet) error // ScaleIn scales in the cluster ScaleIn(tc *v1alpha1.TikvCluster, actual *apps.StatefulSet, desired *apps.StatefulSet) error }
Scaler implements the logic for scaling out or scaling in the cluster.
func NewFakeTiKVScaler ¶
func NewFakeTiKVScaler() Scaler
NewFakeTiKVScaler returns a fake tikv Scaler
func NewPDScaler ¶
func NewPDScaler(pdControl pdapi.PDControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvcControl controller.PVCControlInterface) Scaler
NewPDScaler returns a Scaler
func NewTiKVScaler ¶
func NewTiKVScaler(pdControl pdapi.PDControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvcControl controller.PVCControlInterface, podLister corelisters.PodLister) Scaler
NewTiKVScaler returns a tikv Scaler
type SvcConfig ¶
type SvcConfig struct { Name string Port int32 SvcLabel func(label.Label) label.Label MemberName func(clusterName string) string Headless bool }
SvcConfig corresponds to a K8s service
type TiDBInitInitStartScriptModel ¶
type TiDBInitInitStartScriptModel struct {
ClusterName string
}
type TiKVStartScriptModel ¶
type TiKVStartScriptModel struct {
Scheme string
}
type TidbStartScriptModel ¶
type Upgrader ¶
type Upgrader interface { // Upgrade upgrade the cluster Upgrade(*v1alpha1.TikvCluster, *apps.StatefulSet, *apps.StatefulSet) error }
Upgrader implements the logic for upgrading the tidb cluster.
func NewFakePDUpgrader ¶
func NewFakePDUpgrader() Upgrader
NewFakePDUpgrader returns a fakePDUpgrader
func NewFakeTiKVUpgrader ¶
func NewFakeTiKVUpgrader() Upgrader
NewFakeTiKVUpgrader returns a fake tikv upgrader
func NewPDUpgrader ¶
func NewPDUpgrader(pdControl pdapi.PDControlInterface, podControl controller.PodControlInterface, podLister corelisters.PodLister) Upgrader
NewPDUpgrader returns a pdUpgrader
func NewTiKVUpgrader ¶
func NewTiKVUpgrader(pdControl pdapi.PDControlInterface, podControl controller.PodControlInterface, podLister corelisters.PodLister) Upgrader
NewTiKVUpgrader returns a tikv Upgrader