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

你可能感兴趣的:(k8s学习记录 (gpu调度))