simulator

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const RoutinePodNum = 100

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

Variables

This section is empty.

Functions

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)

func InitKubeSchedulerConfiguration

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

func MatchAndSetLocalStorageAnnotationOnNode added in v0.1.1

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

Types

type AppResource

type AppResource struct {
	Name     string
	Resource ResourceTypes
}

type NodeStatus

type NodeStatus struct {
	// 节点信息
	Node *corev1.Node `json:"node"`
	// 该节点上所有 Pod 信息
	Pods []*corev1.Pod `json:"pods"`
}

已成功调度的 Pod 信息

type Option

type Option func(*simulatorOptions)

Option configures a Simulator

func DisablePTerm added in v0.1.3

func DisablePTerm(disablePTerm bool) Option

func WithExtraRegistry added in v0.1.3

func WithExtraRegistry(extraRegistry frameworkruntime.Registry) Option

func WithKubeConfig

func WithKubeConfig(kubeconfig string) Option

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

func WithPatchPodsFuncMap added in v0.1.3

func WithPatchPodsFuncMap(patchPodsFuncMap PatchPodsFuncMap) Option

func WithSchedulerConfig

func WithSchedulerConfig(schedulerConfig string) Option

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

type PatchPodFunc added in v0.1.3

type PatchPodFunc = func(pods []*corev1.Pod, client externalclientset.Interface) error

type PatchPodsFuncMap added in v0.1.3

type PatchPodsFuncMap map[string]PatchPodFunc

type ResourceTypes

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

func CreateClusterResourceFromClient

func CreateClusterResourceFromClient(client externalclientset.Interface, disablePTerm bool) (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 SimulateResult

type SimulateResult struct {
	UnscheduledPods []UnscheduledPod `json:"unscheduledPods"`
	NodeStatus      []NodeStatus     `json:"nodeStatus"`
}

仿真结果

func Simulate

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

Simulate 参数 1. 由使用方自己生成 cluster 和 apps 传参 2. apps 将按照顺序模拟部署 3. 存储信息以 Json 形式填入对应的 Node 资源中 返回值 1. error 不为空表示函数执行失败 2. error 为空表示函数执行成功,通过 SimulateResult 信息获取集群模拟信息。其中 UnscheduledPods 表示无法调度的 Pods,若其为空表示模拟调度成功;NodeStatus 会详细记录每个 Node 上的 Pod 情况。

type Simulator

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

Simulator is used to simulate a cluster and pods scheduling

func NewSimulator added in v0.1.3

func NewSimulator(opts ...Option) (*Simulator, error)

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

func (*Simulator) Close

func (sim *Simulator) Close()

func (*Simulator) RunCluster

func (sim *Simulator) RunCluster(cluster ResourceTypes) (*SimulateResult, error)

RunCluster

func (*Simulator) ScheduleApp

func (sim *Simulator) ScheduleApp(app AppResource) (*SimulateResult, error)

type UnscheduledPod

type UnscheduledPod struct {
	Pod    *corev1.Pod `json:"pod"`
	Reason string      `json:"reason"`
}

无法成功调度的 Pod 信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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