k8s學習記錄 (gpu調度)

首先,關于NV官方的wiki:

https://github.com/NVIDIA/nvidia-docker/wiki#can-i-limit-the-gpu-resources-eg-bandwidth-memory-cuda-cores-taken-by-a-container

可以看到,截止目前,nvidia-docker無法分配、限制gpu資源。

kubernetes scheduling framework

在小編寫這篇文章的時候,(0202年4月),k8s官方似乎是要把framework作為custom scheduler的方法,不過還是處于alpha版本,可能以后還會有變動。從代碼上看,也確實非常方便

首先,在interface.go里定義了很多interface,如

type QueueSortPlugininterface {

Plugin

? // Less are used to sort pods in the scheduling queue.

? Less(*PodInfo, *PodInfo)bool

}

// PreFilterExtensions is an interface that is included in plugins that allow specifying

// callbacks to make incremental updates to its supposedly pre-calculated

// state.

type PreFilterExtensionsinterface {

// AddPod is called by the framework while trying to evaluate the impact

// of adding podToAdd to the node while scheduling podToSchedule.

? AddPod(ctxcontext.Context, state *CycleState, podToSchedule *v1.Pod, podToAdd *v1.Pod, nodeInfo *schedulernodeinfo.NodeInfo) *Status

? // RemovePod is called by the framework while trying to evaluate the impact

// of removing podToRemove from the node while scheduling podToSchedule.

? RemovePod(ctxcontext.Context, state *CycleState, podToSchedule *v1.Pod, podToRemove *v1.Pod, nodeInfo *schedulernodeinfo.NodeInfo) *Status

}

如果要定制化Scheduler,首先要implement FrameworkHandleinterface

type FrameworkHandleinterface {

// SnapshotSharedLister returns listers from the latest NodeInfo Snapshot. The snapshot

// is taken at the beginning of a scheduling cycle and remains unchanged until

// a pod finishes "Reserve" point. There is no guarantee that the information

// remains unchanged in the binding phase of scheduling, so plugins in the binding

// cycle(permit/pre-bind/bind/post-bind/un-reserve plugin) should not use it,

// otherwise a concurrent read/write error might occur, they should use scheduler

// cache instead.

? SnapshotSharedLister()schedulerlisters.SharedLister

? // IterateOverWaitingPods acquires a read lock and iterates over the WaitingPods map.

? IterateOverWaitingPods(callbackfunc(WaitingPod))

// GetWaitingPod returns a waiting pod given its UID.

? GetWaitingPod(uidtypes.UID)WaitingPod

? // RejectWaitingPod rejects a waiting pod given its UID.

? RejectWaitingPod(uidtypes.UID)

// ClientSet returns a kubernetes clientSet.

? ClientSet()clientset.Interface

? SharedInformerFactory()informers.SharedInformerFactory

}

這些接口是必須有的,定義了一些調度器的基本信息。

然后,就是實現一些調度接口了

var (

_framework.QueueSortPlugin? = &MySched{}

_framework.FilterPlugin? ? = &MySched{}

_framework.PostFilterPlugin = &MySched{}

_framework.ScorePlugin? ? ? = &MySched{}

_framework.ScoreExtensions? = &MySched{}

)

Cobra w Viper

https://github.com/spf13/cobra

https://github.com/spf13/viper

什么是CLI?

CLI就是命令行界面(英語:command-line interface,縮寫:CLI)是在圖形用戶界面得到普及之前使用最為廣泛的用戶界面,它通常不支持鼠標,用戶通過鍵盤輸入指令,計算機接收到指令后,予以執行。

Cobra能夠為app提供CLI命令,自動生成代碼,非常方便。

https://github.com/spf13/cobra/blob/master/cobra/README.md

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容