ctrlcommon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenNonGangSchedulerSetupFunc = func() GangSchedulingSetupFunc {
	return func(jc *ClusterController) {
		jc.Config.GangScheduling = ""
		jc.PodGroupControl = nil
	}
}
View Source
var GenSchedulerPluginsSetupFunc = func(c client.Client, gangSchedulerName string) GangSchedulingSetupFunc {
	return func(jc *ClusterController) {
		jc.Config.GangScheduling = GangScheduler(gangSchedulerName)
		jc.PodGroupControl = control.NewSchedulerPluginsControl(c, gangSchedulerName)
	}
}
View Source
var GenVolcanoSetupFunc = func(vci volcanoclient.Interface) GangSchedulingSetupFunc {
	return func(jc *ClusterController) {
		jc.Config.GangScheduling = GangSchedulerVolcano
		jc.PodGroupControl = control.NewVolcanoControl(vci)
	}
}
View Source
var (
	// KeyFunc is the short name to DeletionHandlingMetaNamespaceKeyFunc.
	// IndexerInformer uses a delta queue, therefore for deletes we have to use this
	// key function but it should be just fine for non delete events.
	KeyFunc = cache.DeletionHandlingMetaNamespaceKeyFunc
)

Functions

func AddResourceList

func AddResourceList(list, req, limit v1.ResourceList)

func CalcPGMinResources

func CalcPGMinResources(minMember int32, replicas map[v1alpha1.ReplicaType]*v1alpha1.ReplicaSpec, pcGetFunc PriorityClassGetFunc) *v1.ResourceList

Types

type ClusterController

type ClusterController struct {
	Controller common.ControllerInterface

	Config ClusterControllerConfiguration

	//TO avoid concurrent read write error
	SchemaReconcilerMutux sync.Mutex

	SchemaReconcilerManager map[cluster_schema.ClusterSchema]common.ClusterSchemaReconciler

	// PodControl is used to add or delete pods.
	PodControl control.PodControlInterface

	// ServiceControl is used to add or delete services.
	ServiceControl control.ServiceControlInterface

	// ConfigMapControl is used to add or delete services.
	ConfigMapControl control.ConfigMapControlInterface

	// KubeClientSet is a standard kubernetes clientset.
	KubeClientSet kubeclientset.Interface

	// PodGroupControl is used to add or delete PodGroup.
	PodGroupControl control.PodGroupControlInterface

	// PodLister can list/get pods from the shared informer's store.
	PodLister corelisters.PodLister

	// ServiceLister can list/get services from the shared informer's store.
	ServiceLister corelisters.ServiceLister

	// PriorityClassLister can list/get priorityClasses from the shared informer's store.
	PriorityClassLister schedulinglisters.PriorityClassLister

	// PodInformerSynced returns true if the pod store has been synced at least once.
	PodInformerSynced cache.InformerSynced

	// ServiceInformerSynced returns true if the service store has been synced at least once.
	ServiceInformerSynced cache.InformerSynced

	// PriorityClassInformerSynced returns true if the priority class store has been synced at least once.
	PriorityClassInformerSynced cache.InformerSynced

	// WorkQueue is a rate limited work queue. This is used to queue work to be
	// processed instead of performing it as soon as a change happens. This
	// means we can ensure we only process a fixed amount of resources at a
	// time, and makes it easy to ensure we are never processing the same item
	// simultaneously in two different workers.
	WorkQueue workqueue.RateLimitingInterface

	// Recorder is an event recorder for recording Event resources to the
	// Kubernetes API.
	Recorder record.EventRecorder
}

ClusterController abstracts other operators to manage the lifecycle of Clusters. User need to first implement the ControllerInterface(objectA) and then initialize a ClusterController(objectB) struct with objectA as the parameter.

func (*ClusterController) CleanUpResources

func (cc *ClusterController) CleanUpResources(
	runPolicy *v1alpha1.RunPolicy,
	runtimeObject runtime.Object,
	metaObject metav1.Object,
	clusterStatus v1alpha1.ClusterStatus,
	pods []*corev1.Pod,
) error

func (*ClusterController) CleanupCluster

func (cc *ClusterController) CleanupCluster(runPolicy *v1alpha1.RunPolicy, runtimeObject runtime.Object, clusterStatus v1alpha1.ClusterStatus) error

func (*ClusterController) CreateNewConfigMap

func (cc *ClusterController) CreateNewConfigMap(kcluster *v1alpha1.KubeCluster, expectations expectation.ControllerExpectationsInterface) (*v1.ConfigMap, error)

func (*ClusterController) CreateNewPod

CreateNewPod creates a new pod for the given index and type.

func (*ClusterController) CreateNewService

CreateNewService creates a new service for the given index and type.

func (*ClusterController) DeletePdb

func (cc *ClusterController) DeletePdb(cluster metav1.Object) error

func (*ClusterController) DeletePodAndServices

func (cc *ClusterController) DeletePodAndServices(runtimeObject runtime.Object, runPolicy *v1alpha1.RunPolicy,
	clusterStatus v1alpha1.ClusterStatus, pods []*corev1.Pod) error

func (*ClusterController) DeletePodGroup

func (cc *ClusterController) DeletePodGroup(cluster metav1.Object) error

func (*ClusterController) FilterPodsForReplicaType

func (cc *ClusterController) FilterPodsForReplicaType(pods []*corev1.Pod, replicaType string) ([]*corev1.Pod, error)

FilterPodsForReplicaType returns pods belong to a replicaType.

func (*ClusterController) FilterServicesForReplicaType

func (cc *ClusterController) FilterServicesForReplicaType(services []*corev1.Service, replicaType string) ([]*corev1.Service, error)

FilterServicesForReplicaType returns service belong to a replicaType.

func (*ClusterController) GenLabels

func (cc *ClusterController) GenLabels(clusterType string) map[string]string

func (*ClusterController) GenOwnerReference

func (cc *ClusterController) GenOwnerReference(obj metav1.Object) *metav1.OwnerReference

func (*ClusterController) GetPodSlices

func (cc *ClusterController) GetPodSlices(pods []*v1.Pod, replicas int, logger *log.Entry) [][]*v1.Pod

GetPodSlices returns a slice, which element is the slice of pod. It gives enough information to caller to make decision to up/down scale resources.

func (*ClusterController) GetPortsFromClusterSpec

func (cc *ClusterController) GetPortsFromClusterSpec(spec *v1alpha1.ReplicaSpec, defaultContainerName string) (map[string]int32, error)

func (*ClusterController) GetSchemaReconciler

func (cc *ClusterController) GetSchemaReconciler(clusterType v1alpha1.ClusterType) common.ClusterSchemaReconciler

func (*ClusterController) PastActiveDeadline

func (cc *ClusterController) PastActiveDeadline(runPolicy *v1alpha1.RunPolicy, clusterStatus v1alpha1.ClusterStatus) bool

PastActiveDeadline checks if cluster has ActiveDeadlineSeconds field set and if it is exceeded.

func (*ClusterController) PastBackoffLimit

func (cc *ClusterController) PastBackoffLimit(clusterName string, runPolicy *v1alpha1.RunPolicy,
	replicas map[v1alpha1.ReplicaType]*v1alpha1.ReplicaSpec, pods []*corev1.Pod) (bool, error)

PastBackoffLimit checks if container restartCounts sum exceeds BackoffLimit this method applies only to pods when restartPolicy is one of OnFailure, Always or ExitCode

func (*ClusterController) ReconcileConfigMap

func (cc *ClusterController) ReconcileConfigMap(kcluster *v1alpha1.KubeCluster) (*v1.ConfigMap, error)

func (*ClusterController) ReconcileKubeCluster

func (cc *ClusterController) ReconcileKubeCluster(kcluster *v1alpha1.KubeCluster, schemaReconciler common.ClusterSchemaReconciler) error

func (*ClusterController) ReconcilePods

func (*ClusterController) ReconcileServices

func (*ClusterController) RegisterSchema

func (cc *ClusterController) RegisterSchema(schema cluster_schema.ClusterSchema, reconciler common.ClusterSchemaReconciler) error

func (*ClusterController) ResetExpectations

func (cc *ClusterController) ResetExpectations(clusterKey string, replicas map[v1alpha1.ReplicaType]*v1alpha1.ReplicaSpec,
	reconciler common.ClusterSchemaReconciler) error

ResetExpectations reset the expectation for creates and deletes of pod/service to zero.

func (*ClusterController) SyncPdb

func (cc *ClusterController) SyncPdb(kcluster metav1.Object, minAvailableReplicas int32) (*policyapi.PodDisruptionBudget, error)

SyncPdb will create a PDB for gang scheduling.

func (*ClusterController) SyncPodGroup

func (cc *ClusterController) SyncPodGroup(cluster metav1.Object, specFunc FillPodGroupSpecFunc) (metav1.Object, error)

type ClusterControllerConfiguration

type ClusterControllerConfiguration struct {
	// GangScheduling choice: None, volcano and scheduler-plugins
	GangScheduling GangScheduler
}

ClusterControllerConfiguration contains configuration of operator.

func (*ClusterControllerConfiguration) EnableGangScheduling

func (c *ClusterControllerConfiguration) EnableGangScheduling() bool

type FillPodGroupSpecFunc

type FillPodGroupSpecFunc func(object metav1.Object) error

type GangScheduler

type GangScheduler string
const (
	GangSchedulerNone    GangScheduler = "None"
	GangSchedulerVolcano GangScheduler = "volcano"
	// GangSchedulerSchedulerPlugins Using this scheduler name or any scheduler name different than volcano uses the scheduler-plugins PodGroup
	GangSchedulerSchedulerPlugins GangScheduler = "scheduler-plugins"
)

type GangSchedulingSetupFunc

type GangSchedulingSetupFunc func(jc *ClusterController)

type PriorityClassGetFunc

type PriorityClassGetFunc func(string) (*schedulingv1.PriorityClass, error)

type ReplicaPriority

type ReplicaPriority struct {
	v1alpha1.ReplicaSpec
	// contains filtered or unexported fields
}

type ReplicasPriority

type ReplicasPriority []ReplicaPriority

ReplicasPriority is a slice of ReplicaPriority.

func (ReplicasPriority) Len

func (p ReplicasPriority) Len() int

func (ReplicasPriority) Less

func (p ReplicasPriority) Less(i, j int) bool

func (ReplicasPriority) Swap

func (p ReplicasPriority) Swap(i, j int)

Jump to

Keyboard shortcuts

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