controller

package
v0.0.0-...-bdc2ea9 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: GPL-3.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConditionTypeReady = "Ready"

	ConditionReasonReconciliationInProgress                              = "ReconciliationInProgress"
	ConditionReasonSecretNotReady                                        = "SecretNotReady"
	ConditionReasonConfigMapNotReady                                     = "ConfigMapNotReady"
	ConditionReasonServicesNotReady                                      = "ServicesNotReady"
	ConditionReasonIngressNotReady                                       = "IngressNotReady"
	ConditionReasonScrapersNotReady                                      = "ScrapersNotReady"
	ConditionReasonMetricsExporterNotReady                               = "MetricsExporterNotReady"
	ConditionReasonQuorumStateUnknown                    ConditionQuorum = "QuorumStateUnknown"
	ConditionReasonQuorumReady                           ConditionQuorum = "QuorumReady"
	ConditionReasonQuorumNotReady                        ConditionQuorum = "QuorumNotReady"
	ConditionReasonQuorumNotReadyWaitATerm               ConditionQuorum = "QuorumNotReadyWaitATerm"
	ConditionReasonQuorumDowngraded                      ConditionQuorum = "QuorumDowngraded"
	ConditionReasonQuorumUpgraded                        ConditionQuorum = "QuorumUpgraded"
	ConditionReasonQuorumNeedsAttentionMemoryOrDiskIssue ConditionQuorum = "QuorumNeedsAttentionMemoryOrDiskIssue"
	ConditionReasonQuorumNeedsAttentionClusterIsLagging  ConditionQuorum = "QuorumNeedsAttentionClusterIsLagging"
	ConditionReasonQuorumQueuedWrites                    ConditionQuorum = "QuorumQueuedWrites"
	ConditionReasonStatefulSetNotReady                                   = "StatefulSetNotReady"

	InitReconciliationMessage = "Starting reconciliation"
	UpdateStatusMessageFailed = "failed to update typesense cluster status"
)

Definitions to manage status conditions

View Source
const (
	ClusterNodesConfigMap           = "%s-nodeslist"
	ClusterAdminApiKeySecret        = "%s-admin-key"
	ClusterAdminApiKeySecretKeyName = "typesense-api-key"

	ClusterHeadlessService = "%s-sts-svc"
	ClusterRestService     = "%s-svc"
	ClusterStatefulSet     = "%s-sts"
	ClusterAppLabel        = "%s-sts"

	ClusterReverseProxyAppLabel  = "%s-rp"
	ClusterReverseProxyIngress   = "%s-reverse-proxy"
	ClusterReverseProxyConfigMap = "%s-reverse-proxy-config"
	ClusterReverseProxy          = "%s-reverse-proxy"
	ClusterReverseProxyService   = "%s-reverse-proxy-svc"

	ClusterPrometheusExporterAppLabel       = "%s-prometheus-exporter"
	ClusterPrometheusExporterDeployment     = "%s-prometheus-exporter"
	ClusterPrometheusExporterService        = "%s-prometheus-exporter-svc"
	ClusterPrometheusExporterServiceMonitor = "%s-prometheus-exporter-servicemonitor"

	ClusterMetricsPodMonitorAppLabel = "%s-sts"
	ClusterMetricsPodMonitor         = "%s-podmonitor"

	ClusterScraperCronJob          = "%s-scraper"
	ClusterScraperCronJobContainer = "%s-docsearch-scraper"
)
View Source
const (
	QuorumReadinessGateCondition = "RaftQuorumReady"
	HealthyWriteLagKey           = "TYPESENSE_HEALTHY_WRITE_LAG"
	HealthyWriteLagDefaultValue  = 500
	HealthyReadLagKey            = "TYPESENSE_HEALTHY_READ_LAG"
	HealthyReadLagDefaultValue   = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterStatus

type ClusterStatus string
const (
	ClusterStatusOK               ClusterStatus = "OK"
	ClusterStatusSplitBrain       ClusterStatus = "SPLIT_BRAIN"
	ClusterStatusNotReady         ClusterStatus = "NOT_READY"
	ClusterStatusElectionDeadlock ClusterStatus = "ELECTION_DEADLOCK"
)

type ConditionQuorum

type ConditionQuorum string

type NodeEndpoint

type NodeEndpoint struct {
	PodName string
	IP      net.IP
}

type NodeHealth

type NodeHealth struct {
	Ok            bool                     `json:"ok"`
	ResourceError *NodeHealthResourceError `json:"resource_error,omitempty"`
}

type NodeHealthResourceError

type NodeHealthResourceError string
const (
	OutOfMemory NodeHealthResourceError = "OUT_OF_MEMORY"
	OutOfDisk   NodeHealthResourceError = "OUT_OF_DISK"
)

type NodeState

type NodeState string
const (
	LeaderState      NodeState = "LEADER"
	FollowerState    NodeState = "FOLLOWER"
	CandidateState   NodeState = "CANDIDATE"
	NotReadyState    NodeState = "NOT_READY"
	ErrorState       NodeState = "ERROR"
	UnreachableState NodeState = "UNREACHABLE"
)

type NodeStatus

type NodeStatus struct {
	CommittedIndex int       `json:"committed_index"`
	QueuedWrites   int       `json:"queued_writes"`
	State          NodeState `json:"state"`
}

type Quorum

type Quorum struct {
	MinRequiredNodes   int
	AvailableNodes     int
	Nodes              map[string]net.IP
	NodesListConfigMap *v1.ConfigMap
}

type TypesenseClusterReconciler

type TypesenseClusterReconciler struct {
	client.Client
	Scheme *runtime.Scheme

	Recorder        record.EventRecorder
	DiscoveryClient *discovery.DiscoveryClient
	// contains filtered or unexported fields
}

TypesenseClusterReconciler reconciles a TypesenseCluster object

func (*TypesenseClusterReconciler) GetFreshStatefulSet

func (r *TypesenseClusterReconciler) GetFreshStatefulSet(ctx context.Context, stsObjectKey client.ObjectKey) (*appsv1.StatefulSet, error)

func (*TypesenseClusterReconciler) IsPrometheusDeployed

func (r *TypesenseClusterReconciler) IsPrometheusDeployed() (bool, error)

func (*TypesenseClusterReconciler) PurgeStatefulSetPods

func (r *TypesenseClusterReconciler) PurgeStatefulSetPods(ctx context.Context, sts *appsv1.StatefulSet) error

func (*TypesenseClusterReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the TypesenseCluster object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.18.4/pkg/reconcile

func (*TypesenseClusterReconciler) ReconcileConfigMap

func (r *TypesenseClusterReconciler) ReconcileConfigMap(ctx context.Context, ts tsv1alpha1.TypesenseCluster) (updated *bool, err error)

func (*TypesenseClusterReconciler) ReconcileIngress

func (r *TypesenseClusterReconciler) ReconcileIngress(ctx context.Context, ts tsv1alpha1.TypesenseCluster) (err error)

func (*TypesenseClusterReconciler) ReconcilePodMonitor

func (*TypesenseClusterReconciler) ReconcileQuorum

func (r *TypesenseClusterReconciler) ReconcileQuorum(ctx context.Context, ts *tsv1alpha1.TypesenseCluster, secret *v1.Secret, stsObjectKey client.ObjectKey) (ConditionQuorum, int, error)

func (*TypesenseClusterReconciler) ReconcileScraper

func (r *TypesenseClusterReconciler) ReconcileScraper(ctx context.Context, ts tsv1alpha1.TypesenseCluster) (err error)

func (*TypesenseClusterReconciler) ReconcileSecret

func (*TypesenseClusterReconciler) ReconcileServices

func (*TypesenseClusterReconciler) ReconcileStatefulSet

func (*TypesenseClusterReconciler) ScaleStatefulSet

func (r *TypesenseClusterReconciler) ScaleStatefulSet(ctx context.Context, stsObjectKey client.ObjectKey, desiredReplicas int32) error

func (*TypesenseClusterReconciler) SetupWithManager

func (r *TypesenseClusterReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type TypesenseClusterReconciliationPhase

type TypesenseClusterReconciliationPhase struct {
	Name      string
	Reconcile func(context.Context, *tsv1alpha1.TypesenseCluster) (ctrl.Result, error)
}

Jump to

Keyboard shortcuts

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