Documentation
¶
Index ¶
- Constants
- func AddReadinessGate(podSpec *corev1.PodSpec, ct corev1.PodConditionType)
- func CNSetImage(mo *v1alpha1.MatrixOneCluster, spec *v1alpha1.CNSetSpec) string
- func CNSetKey(mo *v1alpha1.MatrixOneCluster, name string) metav1.ObjectMeta
- func CloneSetTemplate(o client.Object, name string) *kruisev1alpha1.CloneSet
- func CollectStoreStatus(status *v1alpha1.FailoverStatus, pods []corev1.Pod, fns ...StoreFn)
- func DataDigest(data []byte) string
- func DeploymentTemplate(obj client.Object, name string) *appsv1.Deployment
- func FileServiceConfig(localPath string, sp v1alpha1.SharedStorageProvider, ...) map[string]interface{}
- func GetCNStartedTime(pod *corev1.Pod) *time.Time
- func GetReadinessCondition(pod *corev1.Pod, conditionType corev1.PodConditionType) *corev1.PodCondition
- func GetRuntimeNS() (string, error)
- func GetSemanticVersion(meta *metav1.ObjectMeta) semver.Version
- func GoMemLimitEnv(memPercent *int, memoryLimit *resource.Quantity, overlay *v1alpha1.Overlay) *corev1.EnvVar
- func HashControllerRevision(obj any) (string, error)
- func HeadlessServiceTemplate(obj client.Object, name string) *corev1.Service
- func ListPods(cli recon.KubeClient, opts ...client.ListOption) ([]corev1.Pod, error)
- func LoadOperatorConfig(cfgPath string, config *OperatorConfig) error
- func LogServiceFSConfig(localPath string, sp v1alpha1.SharedStorageProvider) map[string]interface{}
- func LogSetReserveOrdinalsChangedPredicate() predicate.Predicate
- func LogSetStatefulSetOwner(object client.Object) (client.ObjectKey, bool)
- func MustAsSelector(ps *metav1.LabelSelector) labels.Selector
- func MustEqual(key string, value string) labels.Requirement
- func MustNewRequirement(key string, op selection.Operator, vals []string, _ ...field.PathOption) labels.Requirement
- func MustNotHave(key string) labels.Requirement
- func NeedUpdateImage(pod *corev1.Pod) bool
- func NewCNReadinessCondition(status corev1.ConditionStatus, msg string) corev1.PodCondition
- func ObjMetaTemplate[T client.Object](obj T, name string) metav1.ObjectMeta
- func PersistentVolumeClaimTemplate(size resource.Quantity, sc *string, name string) corev1.PersistentVolumeClaim
- func ReferencesLogSet(ref v1alpha1.LogSetRef, dependentNamespace string, key client.ObjectKey) bool
- func ResolveCNSet(cli recon.KubeClient, pod *corev1.Pod) (*v1alpha1.CNSet, error)
- func ResolveLogSet(cli recon.KubeClient, cs *v1alpha1.CNSet) (*v1alpha1.LogSet, error)
- func ResolveOwner(cli recon.KubeClient, pod *corev1.Pod) (client.Object, error)
- func SetStorageProviderConfig(sp v1alpha1.SharedStorageProvider, podSpec *corev1.PodSpec)
- func SetStoreScore(pod *corev1.Pod, s *StoreScore) error
- func SetupMemoryFsVolume(specRef *corev1.PodSpec, memoryFsSize *resource.Quantity)
- func StatefulSetTemplate(obj client.Object, name string, svcName string) *kruise.StatefulSet
- func SubResourceLabels(owner client.Object) map[string]string
- func SyncCloneSetVolumeSize(kubeCli recon.KubeClient, owner client.Object, size resource.Quantity, ...) error
- func SyncConfigMap(kubeCli recon.KubeClient, podSpec *corev1.PodSpec, cm *corev1.ConfigMap, ...) error
- func SyncMOPod(t *SyncMOPodTask) error
- func SyncPodMeta(meta *metav1.ObjectMeta, p *v1alpha1.PodSet)
- func SyncStsVolumeSize(kubeCli recon.KubeClient, owner client.Object, size resource.Quantity, ...) error
- func SyncTopology(domains []string, podSpec *corev1.PodSpec, selector *metav1.LabelSelector)
- func ToStoreLabels(labels []v1alpha1.CNLabel) map[string]metadata.LabelList
- type BrConfig
- type BucketCleanJob
- type OperatorConfig
- type PodStatusChangedPredicate
- type StoreFn
- type StoreScore
- type SyncMOPodTask
Constants ¶
const ( CNStateAnno = "matrixorigin.io/cn-state" CNDrainingFinalizer = "matrixorigin.io/cn-draining" CNStoreReadiness corev1.PodConditionType = "matrixorigin.io/cn-store" ReclaimedAt = "matrixorigin.io/reclaimed-at" SemanticVersionAnno = "matrixorigin.io/semantic-version" )
const ( // ConfigVolume is the volume name of configmap ConfigVolume = "config" // ConfigPath is the path where the config volume will be mounted to ConfigPath = "/etc/matrixone/config" // ConfigFile is the default config file name ConfigFile = "config.toml" // Entrypoint is the entrypoint of mo container Entrypoint = "start.sh" )
const ( LockServicePort = 6003 LogtailPort = 32003 MetricsPort = 7001 DeletionCostAnno = "controller.kubernetes.io/pod-deletion-cost" CNUUIDLabelKey = "matrixone.cloud/cn-uuid" CNLabelAnnotation = "matrixone.cloud/cn-label" PrometheusScrapeAnno = "prometheus.io/scrape" PrometheusPortAnno = "prometheus.io/port" PrometheusPathAnno = "prometheus.io/path" LabelManagedBy = "matrixorigin.io/managed-by" LabelOwnerUID = "matrixorigin.io/owner-uid" ConfigSuffixAnno = "matrixorigin.io/config-suffix" MemoryFsVolume = "tmpfs" MemoryBinPath = "/matrixone/bin" BinPathEnvKey = "MO_BIN_PATH" )
const ( // BackupFileServiceName names the fileservice instance (defined by mo-operator) from which the hakeeper backup data can be read BackupFileServiceName = "BACKUP" AWSAccessKeyID = "AWS_ACCESS_KEY_ID" AWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY" AWSRegion = "AWS_REGION" S3CertificateVolume = "s3-ssl" S3CertificatePath = "/etc/s3-ssl" )
const ( // DataVolume is the volume name of data PV DataVolume = "mo-data" // DataPath is the path where the data volume will be mounted to DataPath = "/var/lib/matrixone" // DataDir is the directory under data path that will be used to store the data of mo disk backend DataDir = "data" // S3CacheDir is the directory under data path that will be used as mo S3 FS cache S3CacheDir = "disk-cache" // InstanceLabelKey labels the cluster instance name of the resource InstanceLabelKey = "matrixorigin.io/instance" // ComponentLabelKey labels the component type of the resource ComponentLabelKey = "matrixorigin.io/component" // NamespaceLabelKey labels the owner namespace of cluster-scope resources NamespaceLabelKey = "matrixorigin.io/namespace" // MatrixoneClusterLabelKey labels pod generated in certain mo cluster MatrixoneClusterLabelKey = "matrixorigin.io/cluster" // ActionRequiredLabelKey labels the resource that need manual intervention ActionRequiredLabelKey = "matrixorigin.io/action-required" // ActionRequiredLabelValue is a dummy value that is used with ActionRequiredLabelKey ActionRequiredLabelValue = "True" // LogSetOwnerKey labels the owner of orphaned LogSet Pod that is left by failover LogSetOwnerKey = "matrixorigin.io/logset-owner" // PodNameEnvKey is the container environment variable to reflect the name of the Pod that runs the container PodNameEnvKey = "POD_NAME" // HeadlessSvcEnvKey is the container environment variable to reflect the headless service name of the Pod that runs the container HeadlessSvcEnvKey = "HEADLESS_SERVICE_NAME" // NamespaceEnvKey is the container environment variable to reflect the namespace of the Pod that runs the container NamespaceEnvKey = "NAMESPACE" // PodIPEnvKey is the container environment variable to reflect the IP of the Pod that runs the container PodIPEnvKey = "POD_IP" // ConfigSuffixEnvKey is the container environment variable to reflect the config suffix ConfigSuffixEnvKey = "CONFIG_SUFFIX" )
const ( PreNameLabelKey = "matrixorigin.io/pre-name" PreUUIDLabelKey = "matrixorigin.io/pre-uuid" // ReasonNoEnoughReadyStores means the resource fall into current condition due to there is no enough ready stores ReasonNoEnoughReadyStores = "NoEnoughReadyStores" // ReasonNoEnoughUpdatedStores means the resource fall into current condition due to there is no enough updated stores ReasonNoEnoughUpdatedStores = "NoEnoughUpdatedStores" )
const (
// AnyIP mean the server can accept connection from anywhere
AnyIP = "0.0.0.0"
)
const (
PodNamespaceEnvKey = "POD_NAMESPACE"
)
Variables ¶
This section is empty.
Functions ¶
func AddReadinessGate ¶
func AddReadinessGate(podSpec *corev1.PodSpec, ct corev1.PodConditionType)
func CNSetImage ¶
func CNSetImage(mo *v1alpha1.MatrixOneCluster, spec *v1alpha1.CNSetSpec) string
func CNSetKey ¶
func CNSetKey(mo *v1alpha1.MatrixOneCluster, name string) metav1.ObjectMeta
func CloneSetTemplate ¶
func CloneSetTemplate(o client.Object, name string) *kruisev1alpha1.CloneSet
CloneSetTemplate return a kruise cloneset as template
func CollectStoreStatus ¶
func CollectStoreStatus(status *v1alpha1.FailoverStatus, pods []corev1.Pod, fns ...StoreFn)
CollectStoreStatus is a template method to collect store status. fns allows the caller to pass a list of functions set the store status according to other information (e.g. query HA Keeper)
func DataDigest ¶
func DeploymentTemplate ¶
func DeploymentTemplate(obj client.Object, name string) *appsv1.Deployment
DeploymentTemplate return a deployment as template
func FileServiceConfig ¶
func FileServiceConfig(localPath string, sp v1alpha1.SharedStorageProvider, cache *v1alpha1.SharedStorageCache) map[string]interface{}
FileServiceConfig generate the fileservice config for an MO component
func GetCNStartedTime ¶
GetCNStartedTime get the CNStarted Time
func GetReadinessCondition ¶
func GetReadinessCondition(pod *corev1.Pod, conditionType corev1.PodConditionType) *corev1.PodCondition
func GetRuntimeNS ¶
func GetSemanticVersion ¶
func GetSemanticVersion(meta *metav1.ObjectMeta) semver.Version
GetSemanticVersion returns the semantic of the target MO pod, if no version is parsed, a dummy version is returned
func GoMemLimitEnv ¶
func HashControllerRevision ¶
func HeadlessServiceTemplate ¶
HeadlessServiceTemplate returns a headless service as template https://kubernetes.io/docs/concepts/services-networking/service/#headless-services
func ListPods ¶
func ListPods(cli recon.KubeClient, opts ...client.ListOption) ([]corev1.Pod, error)
func LoadOperatorConfig ¶
func LoadOperatorConfig(cfgPath string, config *OperatorConfig) error
LoadOperatorConfig read all operator configurations from configmap mount path, and load it into OperatorConfig struct
func LogServiceFSConfig ¶
func LogServiceFSConfig(localPath string, sp v1alpha1.SharedStorageProvider) map[string]interface{}
LogServiceFSConfig generate the fileservice config for log-service
func LogSetReserveOrdinalsChangedPredicate ¶
LogSetReserveOrdinalsChangedPredicate selects updates that change the LogSet service-addresses consumed by CNSet and DNSet configuration. Create and delete events are intentionally ignored: the owning LogSet already drives dependency creation and teardown, and enqueueing dependants from those events would alter their existing lifecycle ordering.
func LogSetStatefulSetOwner ¶
LogSetStatefulSetOwner returns the LogSet controller key for a Kruise StatefulSet. It rejects similarly named resources owned by another API.
func MustAsSelector ¶
func MustAsSelector(ps *metav1.LabelSelector) labels.Selector
func MustNewRequirement ¶
func MustNewRequirement(key string, op selection.Operator, vals []string, _ ...field.PathOption) labels.Requirement
func MustNotHave ¶
func MustNotHave(key string) labels.Requirement
func NeedUpdateImage ¶
NeedUpdateImage checks if the pod needs to update image
func NewCNReadinessCondition ¶
func NewCNReadinessCondition(status corev1.ConditionStatus, msg string) corev1.PodCondition
func ObjMetaTemplate ¶
func ObjMetaTemplate[T client.Object](obj T, name string) metav1.ObjectMeta
ObjMetaTemplate get object metadata
func PersistentVolumeClaimTemplate ¶
func PersistentVolumeClaimTemplate(size resource.Quantity, sc *string, name string) corev1.PersistentVolumeClaim
PersistentVolumeClaimTemplate returns a persistent volume claim object
func ReferencesLogSet ¶
ReferencesLogSet reports whether an internal LogSet reference points to key. Older embedded references may omit namespace; those are local to the dependent object for compatibility with the established API semantics.
func ResolveCNSet ¶
ResolveCNSet resolves the CNSet of an CN Pod
func ResolveLogSet ¶
func ResolveOwner ¶
ResolveOwner resolves the owner set of an MO Pod
func SetStorageProviderConfig ¶
func SetStorageProviderConfig(sp v1alpha1.SharedStorageProvider, podSpec *corev1.PodSpec)
SetStorageProviderConfig set inject configuration of storage provider to Pods
func SetStoreScore ¶
func SetStoreScore(pod *corev1.Pod, s *StoreScore) error
SetStoreScore set the store connection info to Pod anno
func SetupMemoryFsVolume ¶
func StatefulSetTemplate ¶
StatefulSetTemplate return a kruise statefulset as template
func SubResourceLabels ¶
SubResourceLabels generate labels for sub-resources
func SyncCloneSetVolumeSize ¶
func SyncCloneSetVolumeSize(kubeCli recon.KubeClient, owner client.Object, size resource.Quantity, cs *kruisev1alpha1.CloneSet) error
func SyncConfigMap ¶
func SyncConfigMap(kubeCli recon.KubeClient, podSpec *corev1.PodSpec, cm *corev1.ConfigMap, operatorVersion semver.Version) error
SyncConfigMap syncs the desired configmap for pods, which will cause rolling-update if the data of the configmap is changed
func SyncMOPod ¶
func SyncMOPod(t *SyncMOPodTask) error
SyncMOPod execute the given SyncMOPodTask which keeps the pod spec update to date
func SyncPodMeta ¶
func SyncPodMeta(meta *metav1.ObjectMeta, p *v1alpha1.PodSet)
SyncPodMeta sync PodSet to pod object meta
func SyncStsVolumeSize ¶
func SyncStsVolumeSize(kubeCli recon.KubeClient, owner client.Object, size resource.Quantity, sts *kruisev1.StatefulSet) error
SyncStsVolumeSize syncs the volume size of component backed by kruise statefuset
func SyncTopology ¶
func SyncTopology(domains []string, podSpec *corev1.PodSpec, selector *metav1.LabelSelector)
SyncTopology syncs the topology even spread of PodSet to the underlying pods
Types ¶
type BrConfig ¶
type BrConfig struct {
Image string `json:"image,omitempty" yaml:"image,omitempty"`
}
type BucketCleanJob ¶
type BucketCleanJob struct {
Image string `json:"image,omitempty" yaml:"image,omitempty"`
}
type OperatorConfig ¶
type OperatorConfig struct {
DefaultArgs *v1alpha1.DefaultArgs `json:"defaultArgs,omitempty" yaml:"defaultArgs,omitempty"`
FeatureGates map[string]bool `json:"featureGates,omitempty" yaml:"featureGates,omitempty"`
BRConfig BrConfig `json:"brConfig,omitempty" yaml:"brConfig,omitempty"`
BucketCleanJob BucketCleanJob `json:"bucketCleanJob,omitempty" yaml:"bucketCleanJob,omitempty"`
OnlyWatchReleasedNS bool `json:"onlyWatchReleasedNS,omitempty" yaml:"onlyWatchReleasedNS,omitempty"`
}
OperatorConfig includes configurations for this operator process
type PodStatusChangedPredicate ¶
func (PodStatusChangedPredicate) Update ¶
func (PodStatusChangedPredicate) Update(e event.UpdateEvent) bool
Update implements default UpdateEvent filter for validating resource version change.
type StoreScore ¶
type StoreScore struct {
SessionCount int `json:"sessionCount"`
PipelineCount int `json:"pipelineCount"`
ReplicaCount int `json:"replicaCount"`
// The observed fields distinguish a confirmed count from a zero value left by a
// skipped, failed, or incomplete query. Old annotations do not contain these
// fields and are deliberately unsafe until a fresh observation succeeds.
SessionObserved bool `json:"sessionObserved"`
PipelineObserved bool `json:"pipelineObserved"`
ReplicaObserved bool `json:"replicaObserved"`
StartedTime *time.Time `json:"startedTime,omitempty"`
}
func GetStoreScore ¶
func GetStoreScore(pod *corev1.Pod) (*StoreScore, error)
GetStoreScore get the store connection count from Pod anno
func (*StoreScore) BeginObservation ¶
func (s *StoreScore) BeginObservation(startedTime *time.Time)
BeginObservation invalidates the previous round before any query starts. Counts are kept for diagnostics and deletion cost unless the CN process restarted, but they cannot authorize reclaim until every required observation succeeds again.
func (*StoreScore) GenDeletionCost ¶
func (s *StoreScore) GenDeletionCost() int
func (*StoreScore) IsSafeToReclaim ¶
func (s *StoreScore) IsSafeToReclaim() bool
type SyncMOPodTask ¶
type SyncMOPodTask struct {
PodSet *v1alpha1.PodSet
TargetTemplate *corev1.PodTemplateSpec
ConfigMap *corev1.ConfigMap
KubeCli recon.KubeClient
StorageProvider *v1alpha1.SharedStorageProvider
ConfigSuffix string
// optional
MutateContainer func(c *corev1.Container)
MutatePod func(p *corev1.PodTemplateSpec)
}