首先敬察,關(guān)于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
在小編寫這篇文章的時(shí)候,(0202年4月),k8s官方似乎是要把framework作為custom scheduler的方法棵里,不過還是處于alpha版本润文,可能以后還會(huì)有變動(dòng)。從代碼上看殿怜,也確實(shí)非常方便
首先典蝌,在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
}
這些接口是必須有的骏掀,定義了一些調(diào)度器的基本信息。
然后柱告,就是實(shí)現(xiàn)一些調(diào)度接口了
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)是在圖形用戶界面得到普及之前使用最為廣泛的用戶界面际度,它通常不支持鼠標(biāo)葵袭,用戶通過鍵盤輸入指令,計(jì)算機(jī)接收到指令后乖菱,予以執(zhí)行坡锡。
Cobra能夠?yàn)閍pp提供CLI命令,自動(dòng)生成代碼窒所,非常方便鹉勒。
https://github.com/spf13/cobra/blob/master/cobra/README.md