utils

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: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// open-local storage class names
	OpenLocalSCNameLVM           = "open-local-lvm"
	OpenLocalSCNameDeviceHDD     = "open-local-device-hdd"
	OpenLocalSCNameDeviceSSD     = "open-local-device-ssd"
	OpenLocalSCNameMountPointHDD = "open-local-mountpoint-hdd"
	OpenLocalSCNameMountPointSSD = "open-local-mountpoint-ssd"

	// yoda storage class names
	YodaSCNameLVM           = "yoda-lvm-default"
	YodaSCNameDeviceHDD     = "yoda-device-hdd"
	YodaSCNameDeviceSSD     = "yoda-device-ssd"
	YodaSCNameMountPointHDD = "yoda-mountpoint-hdd"
	YodaSCNameMountPointSSD = "yoda-mountpoint-ssd"
)

Variables

This section is empty.

Functions

func AddWorkloadInfoToPod

func AddWorkloadInfoToPod(pod *corev1.Pod, kind string, name string, namespace string) *corev1.Pod

AddWorkloadInfoToPod add annotation in pod for simulating later

func AdjustNodesOrder

func AdjustNodesOrder(nodes []string) []string

func AdjustWorkloads

func AdjustWorkloads(workloads map[string][]string)

func CreateKubeClient

func CreateKubeClient(kubeconfig string) (*clientset.Clientset, error)

func DecodeYamlContent

func DecodeYamlContent(yamlRes []byte) ([]runtime.Object, error)

DecodeYamlContent captures the yml or yaml file, and decodes it

func GetGpuNodeInfoFromAnnotation added in v0.1.1

func GetGpuNodeInfoFromAnnotation(node *corev1.Node) (*gpusharecache.NodeGpuInfo, error)

func GetMasterFromKubeConfig

func GetMasterFromKubeConfig(filename string) (string, error)

func GetNodeAllocatable

func GetNodeAllocatable(node *corev1.Node) (resource.Quantity, resource.Quantity)

func GetNodeCache

func GetNodeCache(node *corev1.Node) (*localcache.NodeCache, error)

func GetPodsTotalRequestsAndLimitsByNodeName

func GetPodsTotalRequestsAndLimitsByNodeName(pods []corev1.Pod, nodeName string) (map[corev1.ResourceName]resource.Quantity, map[corev1.ResourceName]resource.Quantity)

func GetYamlContentFromDirectory

func GetYamlContentFromDirectory(dir string) ([]string, error)

GetYamlContentFromDirectory returns the yaml content and ignores other content

func MakeValidNodeByNode

func MakeValidNodeByNode(node *corev1.Node, nodename string) (*corev1.Node, error)

func MakeValidPod

func MakeValidPod(oldPod *corev1.Pod) (*corev1.Pod, error)

MakeValidPod make pod valid, so we can handle it

func MakeValidPodByCronJob

func MakeValidPodByCronJob(cronjob *batchv1beta1.CronJob) ([]*corev1.Pod, error)

func MakeValidPodByJob

func MakeValidPodByJob(job *batchv1.Job) ([]*corev1.Pod, error)

func MakeValidPodByPod

func MakeValidPodByPod(pod *corev1.Pod) (*corev1.Pod, error)

func MakeValidPodsByDaemonset

func MakeValidPodsByDaemonset(ds *appsv1.DaemonSet, nodes []*corev1.Node) ([]*corev1.Pod, error)

func MakeValidPodsByDeployment

func MakeValidPodsByDeployment(deploy *appsv1.Deployment) ([]*corev1.Pod, error)

func MakeValidPodsByReplicaSet

func MakeValidPodsByReplicaSet(rs *appsv1.ReplicaSet) ([]*corev1.Pod, error)

func MakeValidPodsByStatefulSet

func MakeValidPodsByStatefulSet(ss *appsv1.StatefulSet) ([]*corev1.Pod, error)

func MultiplyMilliQuant

func MultiplyMilliQuant(quant resource.Quantity, factor float64) resource.Quantity

MultiplyMilliQuant scales quantity by factor

func MultiplyQuant

func MultiplyQuant(quant resource.Quantity, factor float64) resource.Quantity

MultiplyQuant scales quantity by factor

func NewDaemonPod

func NewDaemonPod(ds *appsv1.DaemonSet, nodeName string) (*corev1.Pod, error)

func NewFakeNode added in v0.1.3

func NewFakeNode(node *corev1.Node) (*corev1.Node, error)

func NewFakeNodes added in v0.1.3

func NewFakeNodes(node *corev1.Node, nodeCount int) ([]*corev1.Node, error)

func NodeShouldRunPod

func NodeShouldRunPod(node *corev1.Node, pod *corev1.Pod) bool

NodeShouldRunPod determines whether a node should run a pod according to scheduling rules

func OwnedByDaemonset added in v0.1.3

func OwnedByDaemonset(refs []metav1.OwnerReference) bool

func OwnedByWorkload added in v0.1.3

func OwnedByWorkload(refs []metav1.OwnerReference, workload runtime.Object) bool

func ParseFilePath

func ParseFilePath(path string) (filePaths []string, err error)

ParseFilePath converts recursively directory path to a slice of file paths

func ReadJsonFile

func ReadJsonFile(path string) []byte

func ReadYamlFile

func ReadYamlFile(path string) []byte

func SetDaemonSetPodNodeNameByNodeAffinity

func SetDaemonSetPodNodeNameByNodeAffinity(affinity *corev1.Affinity, nodename string) *corev1.Affinity

func SetObjectMetaFromObject

func SetObjectMetaFromObject(owner metav1.Object, template metav1.Object) metav1.ObjectMeta

func SetStorageAnnotationOnPods

func SetStorageAnnotationOnPods(pods []*corev1.Pod, volumeClaimTemplates []corev1.PersistentVolumeClaim, stsName string) error

func ValidateNode

func ValidateNode(node *corev1.Node) error

ValidateNode check if node is valid

func ValidatePod

func ValidatePod(pod *corev1.Pod) error

ValidatePod check if pod is valid

Types

type NodeQueue

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

func NewNodeQueue

func NewNodeQueue(nodes []string) *NodeQueue

func (*NodeQueue) Len

func (queue *NodeQueue) Len() int

func (*NodeQueue) Less

func (queue *NodeQueue) Less(i, j int) bool

func (*NodeQueue) Swap

func (queue *NodeQueue) Swap(i, j int)

type NodeStorage

type NodeStorage struct {
	VGs     []localcache.SharedResource    `json:"vgs"`
	Devices []localcache.ExclusiveResource `json:"devices"`
}

func GetNodeStorage

func GetNodeStorage(node *corev1.Node) (*NodeStorage, error)

type Volume

type Volume struct {
	Size int64 `json:"size,string"`
	// Kind 可以是 LVM 或 HDD 或 SSD
	// HDD 和 SSD 均指代独占盘
	Kind             string `json:"kind"`
	StorageClassName string `json:"scName"`
}

type VolumeRequest

type VolumeRequest struct {
	Volumes []Volume `json:"volumes"`
}

func GetPodStorage

func GetPodStorage(pod *corev1.Pod) *VolumeRequest

Jump to

Keyboard shortcuts

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