simulator

package
v0.0.0-...-f2569be Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagInitSchedule        = "InitSchedule"
	TagPostEviction        = "PostEviction"
	TagPostDeschedule      = "PostDeschedule"
	TagScheduleInflation   = "ScheduleInflation"
	TagDescheduleInflation = "DescheduleInflation"
)
View Source
const (
	DeschedulePolicyCosSim       = "cosSim"
	DeschedulePolicyFragOnePod   = "fragOnePod"
	DeschedulePolicyFragMultiPod = "fragMultiPod"
)

Variables

This section is empty.

Functions

func ClearPodUnscheduledAnno

func ClearPodUnscheduledAnno(pod *corev1.Pod)

func GenerateValidPodsFromAppResources

func GenerateValidPodsFromAppResources(client externalclientset.Interface, appname string, resources ResourceTypes) ([]*corev1.Pod, error)

GenerateValidPodsFromAppResources generate valid pods from resources

func GetAndSetSchedulerConfig

func GetAndSetSchedulerConfig(schedulerConfig string) (*config.CompletedConfig, error)

GetAndSetSchedulerConfig gets scheduler CompletedConfig and sets the list of scheduler bind plugins to Simon.

func GetValidPodExcludeDaemonSet

func GetValidPodExcludeDaemonSet(resources ResourceTypes) ([]*corev1.Pod, error)

GetValidPodExcludeDaemonSet gets valid pod by resources exclude DaemonSet that needs to be handled specially

func InitKubeSchedulerConfiguration

func InitKubeSchedulerConfiguration(opts *schedoptions.Options) (*schedconfig.CompletedConfig, error)

func IsPodMarkedUnscheduledAnno

func IsPodMarkedUnscheduledAnno(pod *corev1.Pod) bool

func MakePodUnassigned

func MakePodUnassigned(oldPod *corev1.Pod) (newPod *corev1.Pod)

func MarkPodUnscheduledAnno

func MarkPodUnscheduledAnno(pod *corev1.Pod)

MarkPodUnscheduledAnno will directly modify the input and add an unscheduled annotation

func MatchAndSetLocalStorageAnnotationOnNode

func MatchAndSetLocalStorageAnnotationOnNode(nodes []*corev1.Node, dir string)

MatchAndSetLocalStorageAnnotationOnNode add storage information configured by json file, belonging to the node that matches the json file name, to annotation of this node

func RemovePodsByIndex

func RemovePodsByIndex(s []*corev1.Pod, index int) []*corev1.Pod

func Simulate

func Simulate(cluster ResourceTypes, apps []AppResource, opts ...Option) (*simontype.SimulateResult, error)

Simulate is used for simulating and deploying apps in a cluster. It takes in the cluster and apps generated by the user as parameters, and deploys the apps in order. Return Values 1. If error is not empty, the function execution failed. 2. If error is empty, the function executes successfully and the SimulateResult information can be used to get the cluster simulation information. The SimulateResult information includes: 1. UnscheduledPods - represents unscheduled Pods. If the value is empty, it means that the simulation scheduling was successful. 2. NodeStatus - will record the Pod situation on each Node in detail.

Types

type AppResource

type AppResource struct {
	Name     string
	Resource ResourceTypes
}

type Interface

type Interface interface {
	RunCluster(cluster ResourceTypes) ([]simontype.UnscheduledPod, error)
	ScheduleApp(AppResource) ([]simontype.UnscheduledPod, error)
	SchedulePods(pods []*corev1.Pod) []simontype.UnscheduledPod

	ClusterAnalysis(tag string) (utils.FragAmount, []utils.ResourceSummary)
	ClusterGpuFragReport()
	GetClusterNodeStatus() []simontype.NodeStatus

	SetWorkloadPods(pods []*corev1.Pod)
	SetTypicalPods()
	SetSkylinePods()

	RecordPodTotalResourceReq(pods []*corev1.Pod) (int64, int64)
	RecordNodeTotalResource(nodes []*corev1.Node) (int64, int64)

	TunePodsByNodeTotalResource(pods []*corev1.Pod, config v1alpha1.WorkloadTuningConfig) []*corev1.Pod

	ExportPodSnapshotInYaml(unschedulePods []simontype.UnscheduledPod, filePath string)
	ExportNodeSnapshotInCSV(filePath string)
	ExportPodSnapshotInCSV(filePath string)

	SortClusterPods(pods []*corev1.Pod)

	RunWorkloadInflationEvaluation(tag string)

	GetCustomConfig() v1alpha1.CustomConfig

	DescheduleCluster() []simontype.UnscheduledPod

	Close()
}

func New

func New(opts ...Option) (Interface, error)

New generates all components that will be needed to simulate scheduling and returns a complete simulator

type Item

type Item struct {
	// contains filtered or unexported fields
}

An Item is something we manage in a priority queue.

type Option

type Option func(*simulatorOptions)

Option configures a Simulator

func WithCustomConfig

func WithCustomConfig(customConfig v1alpha1.CustomConfig) Option

func WithKubeConfig

func WithKubeConfig(kubeconfig string) Option

WithKubeConfig sets kubeconfig for Simulator, the default value is ""

func WithSchedulerConfig

func WithSchedulerConfig(schedulerConfig string) Option

WithSchedulerConfig sets schedulerConfig for Simulator, the default value is ""

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type ResourceTypes

type ResourceTypes struct {
	Nodes                  []*corev1.Node
	Pods                   []*corev1.Pod
	DaemonSets             []*appsv1.DaemonSet
	StatefulSets           []*appsv1.StatefulSet
	Deployments            []*appsv1.Deployment
	ReplicationControllers []*corev1.ReplicationController
	ReplicaSets            []*appsv1.ReplicaSet
	Services               []*corev1.Service
	PersistentVolumeClaims []*corev1.PersistentVolumeClaim
	StorageClasss          []*storagev1.StorageClass
	PodDisruptionBudgets   []*policyv1beta1.PodDisruptionBudget
	Jobs                   []*batchv1.Job
	CronJobs               []*batchv1beta1.CronJob
}

func CreateClusterResourceFromClient

func CreateClusterResourceFromClient(client externalclientset.Interface) (ResourceTypes, error)

CreateClusterResourceFromClient returns a ResourceTypes struct by kube-client that connects a real cluster

func CreateClusterResourceFromClusterConfig

func CreateClusterResourceFromClusterConfig(path string) (ResourceTypes, error)

CreateClusterResourceFromClusterConfig return a ResourceTypes struct based on the cluster config

func GetObjectFromYamlContent

func GetObjectFromYamlContent(ymlStr []string) (ResourceTypes, error)

GetObjectFromYamlContent decodes the yaml content and returns the kubernetes objects

type Simulator

type Simulator struct {
	// contains filtered or unexported fields
}

Simulator is used to simulate a cluster and pods scheduling

func (*Simulator) Close

func (sim *Simulator) Close()

func (*Simulator) ClusterAnalysis

func (sim *Simulator) ClusterAnalysis(tag string) (utils.FragAmount, []utils.ResourceSummary)

func (*Simulator) ClusterGpuFragReport

func (sim *Simulator) ClusterGpuFragReport()

ClusterGpuFragReport Reports the Gpu Frag Amount of all nodes

func (*Simulator) DescheduleCluster

func (sim *Simulator) DescheduleCluster() []simontype.UnscheduledPod

func (*Simulator) ExportNodeSnapshotInCSV

func (sim *Simulator) ExportNodeSnapshotInCSV(filePath string)

func (*Simulator) ExportPodSnapshotInCSV

func (sim *Simulator) ExportPodSnapshotInCSV(filePath string)

func (*Simulator) ExportPodSnapshotInYaml

func (sim *Simulator) ExportPodSnapshotInYaml(unschedulePods []simontype.UnscheduledPod, filePath string)

func (*Simulator) GetClusterNodeStatus

func (sim *Simulator) GetClusterNodeStatus() []simontype.NodeStatus

func (*Simulator) GetCustomConfig

func (sim *Simulator) GetCustomConfig() v1alpha1.CustomConfig

func (*Simulator) NodeGpuFragAmount

func (sim *Simulator) NodeGpuFragAmount(nodeRes simontype.NodeResource) utils.FragAmount

func (*Simulator) NodeGpuFragAmountMap

func (sim *Simulator) NodeGpuFragAmountMap(nodeResourceMap map[string]simontype.NodeResource) map[string]utils.FragAmount

func (*Simulator) RecordNodeTotalResource

func (sim *Simulator) RecordNodeTotalResource(nodes []*corev1.Node) (int64, int64)

RecordNodeTotalResource will record the total resources of all nodes, and return the list: [total milli cpu of all nodes, total milli gpu of all nodes]

func (*Simulator) RecordPodTotalResourceReq

func (sim *Simulator) RecordPodTotalResourceReq(pods []*corev1.Pod) (int64, int64)

RecordPodTotalResourceReq will record the total resource requests of all pods, and return the list: [total milli cpu request of all pods, total milli gpu request of all pods]

func (*Simulator) ReportFragBasedOnSkyline

func (sim *Simulator) ReportFragBasedOnSkyline()

func (*Simulator) RunCluster

func (sim *Simulator) RunCluster(cluster ResourceTypes) ([]simontype.UnscheduledPod, error)

RunCluster with real client in a production cluster or fake client in a simulated cluster.

func (*Simulator) RunWorkloadInflationEvaluation

func (sim *Simulator) RunWorkloadInflationEvaluation(tag string)

func (*Simulator) ScheduleApp

func (sim *Simulator) ScheduleApp(apps AppResource) ([]simontype.UnscheduledPod, error)

func (*Simulator) SchedulePods

func (sim *Simulator) SchedulePods(pods []*corev1.Pod) []simontype.UnscheduledPod

func (*Simulator) SetSkylinePods

func (sim *Simulator) SetSkylinePods()

func (*Simulator) SetTypicalPods

func (sim *Simulator) SetTypicalPods()

func (*Simulator) SetWorkloadPods

func (sim *Simulator) SetWorkloadPods(pods []*corev1.Pod)

func (*Simulator) SortClusterPods

func (sim *Simulator) SortClusterPods(pods []*corev1.Pod)

func (*Simulator) TunePodsByNodeTotalResource

func (sim *Simulator) TunePodsByNodeTotalResource(pods []*corev1.Pod, cfg v1alpha1.WorkloadTuningConfig) []*corev1.Pod

TunePodsByNodeTotalResource prune or append pods to match the cfg.Ratio * (cluster_GPU_capacity)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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