common

package
v0.0.0-...-42b859f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
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"
)
View Source
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"
)
View Source
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"
)
View Source
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"
)
View Source
const (
	// AnyIP mean the server can accept connection from anywhere
	AnyIP = "0.0.0.0"
)

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 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 GetReadinessCondition

func GetReadinessCondition(pod *corev1.Pod, conditionType corev1.PodConditionType) *corev1.PodCondition

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 GoMemLimitEnv(memPercent *int, memoryLimit *resource.Quantity, overlay *v1alpha1.Overlay) *corev1.EnvVar

func HashControllerRevision

func HashControllerRevision(obj any) (string, error)

func HeadlessServiceTemplate

func HeadlessServiceTemplate(obj client.Object, name string) *corev1.Service

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 MustAsSelector

func MustAsSelector(ps *metav1.LabelSelector) labels.Selector

func MustEqual

func MustEqual(key string, value string) labels.Requirement

func MustNewRequirement

func MustNewRequirement(key string, op selection.Operator, vals []string, _ ...field.PathOption) labels.Requirement

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 ResolveCNSet

func ResolveCNSet(cli recon.KubeClient, pod *corev1.Pod) (*v1alpha1.CNSet, error)

ResolveCNSet resolves the CNSet of an CN Pod

func ResolveLogSet

func ResolveLogSet(cli recon.KubeClient, cs *v1alpha1.CNSet) (*v1alpha1.LogSet, error)

func ResolveOwner

func ResolveOwner(cli recon.KubeClient, pod *corev1.Pod) (client.Object, error)

ResolveOwner resolves the owner set of an MO Pod

func SetSematicVersion

func SetSematicVersion(meta *metav1.ObjectMeta, p *v1alpha1.PodSet)

SetSematicVersion set pod semantic version to pod object meta

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 StatefulSetTemplate

func StatefulSetTemplate(obj client.Object, name string, svcName string) *kruise.StatefulSet

StatefulSetTemplate return a kruise statefulset as template

func SubResourceLabels

func SubResourceLabels(owner client.Object) map[string]string

SubResourceLabels generate labels for sub-resources

func SyncConfigMap

func SyncConfigMap(kubeCli recon.KubeClient, podSpec *corev1.PodSpec, cm *corev1.ConfigMap) 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 SyncTopology

func SyncTopology(domains []string, podSpec *corev1.PodSpec, selector *metav1.LabelSelector)

SyncTopology syncs the topology even spread of PodSet to the underlying pods

func ToStoreLabels

func ToStoreLabels(labels []v1alpha1.CNLabel) map[string]metadata.LabelList

ToStoreLabels transform a list of CNLabel to CNStore Label

Types

type BrConfig

type BrConfig 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"`
}

OperatorConfig includes configurations for this operator process

type StoreFn

type StoreFn func(store *v1alpha1.Store)

type StoreScore

type StoreScore struct {
	SessionCount  int `json:"sessionCount"`
	PipelineCount int `json:"pipelineCount"`
}

func GetStoreScore

func GetStoreScore(pod *corev1.Pod) (*StoreScore, error)

GetStoreScore get the store connection count from Pod anno

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

	// optional
	MutateContainer func(c *corev1.Container)
	MutatePod       func(p *corev1.PodTemplateSpec)
}

Jump to

Keyboard shortcuts

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