Documentation
¶
Overview ¶
Package kubeclient a series of k8s function
Package kubeclient a series of k8s function ¶
Package kubeclient a series of k8s function ¶
Package kubeclient a series of k8s function ¶
Package kubeclient a series of k8s function
Index ¶
- Constants
- func GetNodeNameFromEnv() (string, error)
- func UpdatePodList(newObj interface{}, operator EventType)
- type ClientK8s
- func (ki *ClientK8s) AddAnnotation(key, value string) error
- func (ki *ClientK8s) AnnotationReset() error
- func (ki *ClientK8s) ClearResetInfo(taskName, namespace string) error
- func (ki *ClientK8s) CreateConfigMap(cm *v1.ConfigMap) (*v1.ConfigMap, error)
- func (ki *ClientK8s) CreateEvent(evt *v1.Event) (*v1.Event, error)
- func (ki *ClientK8s) FlushPodCacheNextQuerying()
- func (ki *ClientK8s) GetActivePodList() ([]v1.Pod, error)
- func (ki *ClientK8s) GetActivePodListCache() []v1.Pod
- func (ki *ClientK8s) GetAllPodList() (*v1.PodList, error)
- func (ki *ClientK8s) GetAllPodListCache() []v1.Pod
- func (ki *ClientK8s) GetConfigMap(cmName, cmNameSpace string) (*v1.ConfigMap, error)
- func (ki *ClientK8s) GetDeviceInfoCMCache() *common.NodeDeviceInfoCache
- func (ki *ClientK8s) GetManuallySeparateNPUIDFromDeviceInfo(deviceInfoCMName, deviceInfoCMNamespace string) []int32
- func (ki *ClientK8s) GetNode() (*v1.Node, error)
- func (ki *ClientK8s) GetNodeServerID() (string, error)
- func (ki *ClientK8s) GetNodeServerIDCache() (string, error)
- func (ki *ClientK8s) GetPod(pod *v1.Pod) (*v1.Pod, error)
- func (ki *ClientK8s) GetPodsUsedNPUByKlt() sets.String
- func (ki *ClientK8s) GetPodsUsedNpuByCommon() sets.String
- func (ki *ClientK8s) GetServerUsageLabelCache() (string, error)
- func (ki *ClientK8s) InitPodInformer()
- func (ki *ClientK8s) PatchNodeState(curNode, newNode *v1.Node) (*v1.Node, []byte, error)
- func (ki *ClientK8s) PatchPod(pod *v1.Pod, data []byte) (*v1.Pod, error)
- func (ki *ClientK8s) PodInformerInspector(ctx context.Context)
- func (ki *ClientK8s) ResetDeviceInfo()
- func (ki *ClientK8s) ResourceEventHandler(res ResourceType, filter func(obj interface{}) bool) ...
- func (ki *ClientK8s) SetNodeDeviceInfoCache(deviceInfoCache *common.NodeDeviceInfoCache)
- func (ki *ClientK8s) TryUpdatePodAnnotation(pod *v1.Pod, annotation map[string]string) error
- func (ki *ClientK8s) TryUpdatePodCacheAnnotation(pod *v1.Pod, annotation map[string]string) error
- func (ki *ClientK8s) UpdateConfigMap(cm *v1.ConfigMap) (*v1.ConfigMap, error)
- func (ki *ClientK8s) UpdatePod(pod *v1.Pod) (*v1.Pod, error)
- func (ki *ClientK8s) WriteDeviceInfoDataIntoCM(deviceInfo map[string]string, manuallySeparateNPU string, ...) (*common.NodeDeviceInfoCache, error)
- func (ki *ClientK8s) WriteDeviceInfoDataIntoCMCache(deviceInfo map[string]string, manuallySeparateNPU string, ...) error
- func (ki *ClientK8s) WriteFaultInfoDataIntoCM(taskName string, namespace string, faultInfo *common.TaskFaultInfo) (*v1.ConfigMap, error)
- func (ki *ClientK8s) WriteResetInfoDataIntoCM(taskName string, namespace string, taskInfo *common.TaskResetInfo, ...) (*v1.ConfigMap, error)
- type Event
- type EventType
- type ResourceType
Constants ¶
const ( // HostIPEnv represents the env for HOST_IP HostIPEnv = "HOST_IP" // KubeletPortEnv represents the env for KUBELET_PORT KubeletPortEnv = "KUBELET_PORT" // DefaultKubeletPort represents the default listening port for the kubelet service DefaultKubeletPort = "10250" // MaxPortIntValue represents the max value of port MaxPortIntValue = 65535 )
Variables ¶
This section is empty.
Functions ¶
func GetNodeNameFromEnv ¶
GetNodeNameFromEnv get current node name from env
func UpdatePodList ¶
func UpdatePodList(newObj interface{}, operator EventType)
UpdatePodList update pod list by informer
Types ¶
type ClientK8s ¶
type ClientK8s struct { Clientset kubernetes.Interface NodeName string DeviceInfoName string IsApiErr bool PodInformer cache.SharedIndexInformer Queue workqueue.RateLimitingInterface KltClient *http.Client }
ClientK8s include ClientK8sSet & nodeName & configmap name & kubelet http Client
func (*ClientK8s) AddAnnotation ¶
AddAnnotation add annotation
func (*ClientK8s) AnnotationReset ¶
AnnotationReset reset annotation and device info
func (*ClientK8s) ClearResetInfo ¶
ClearResetInfo clear reset info
func (*ClientK8s) CreateConfigMap ¶
CreateConfigMap create device info, which is cm
func (*ClientK8s) CreateEvent ¶
CreateEvent create event resource
func (*ClientK8s) FlushPodCacheNextQuerying ¶
func (ki *ClientK8s) FlushPodCacheNextQuerying()
FlushPodCacheNextQuerying next time querying pod, flush cache
func (*ClientK8s) GetActivePodList ¶
GetActivePodList is to get active pod list
func (*ClientK8s) GetActivePodListCache ¶
GetActivePodListCache is to get active pod list with cache
func (*ClientK8s) GetAllPodList ¶
GetAllPodList get pod list by field selector
func (*ClientK8s) GetAllPodListCache ¶
GetAllPodListCache get pod list by field selector with cache,
func (*ClientK8s) GetConfigMap ¶
GetConfigMap get config map by name and namespace
func (*ClientK8s) GetDeviceInfoCMCache ¶
func (ki *ClientK8s) GetDeviceInfoCMCache() *common.NodeDeviceInfoCache
GetDeviceInfoCMCache get device info configMap with cache
func (*ClientK8s) GetManuallySeparateNPUIDFromDeviceInfo ¶
func (ki *ClientK8s) GetManuallySeparateNPUIDFromDeviceInfo(deviceInfoCMName, deviceInfoCMNamespace string) []int32
GetManuallySeparateNPUIDFromDeviceInfo returns the ManuallySeparateNPU from device info
func (*ClientK8s) GetNodeServerID ¶
GetNodeServerID Get Node Server ID
func (*ClientK8s) GetNodeServerIDCache ¶
GetNodeServerIDCache Get Node Server ID with cache
func (*ClientK8s) GetPodsUsedNPUByKlt ¶
GetPodsUsedNPUByKlt returns NPUs used by Pods
func (*ClientK8s) GetPodsUsedNpuByCommon ¶
GetPodsUsedNpuByCommon get npu by status
func (*ClientK8s) GetServerUsageLabelCache ¶
GetServerUsageLabelCache get node label:server-usage, and cache it in memory, if label updated, restart is required if server-usage label is set return the value of label if server-usage label is not set return 'unknown'
func (*ClientK8s) InitPodInformer ¶
func (ki *ClientK8s) InitPodInformer()
InitPodInformer init pod informer
func (*ClientK8s) PatchNodeState ¶
PatchNodeState patch node state
func (*ClientK8s) PodInformerInspector ¶
PodInformerInspector check pod in cache
func (*ClientK8s) ResetDeviceInfo ¶
func (ki *ClientK8s) ResetDeviceInfo()
ResetDeviceInfo reset device info
func (*ClientK8s) ResourceEventHandler ¶
func (ki *ClientK8s) ResourceEventHandler(res ResourceType, filter func(obj interface{}) bool) cache. ResourceEventHandler
ResourceEventHandler handle the configmap resource event
func (*ClientK8s) SetNodeDeviceInfoCache ¶
func (ki *ClientK8s) SetNodeDeviceInfoCache(deviceInfoCache *common.NodeDeviceInfoCache)
SetNodeDeviceInfoCache set device info cache
func (*ClientK8s) TryUpdatePodAnnotation ¶
TryUpdatePodAnnotation is to try updating pod annotation
func (*ClientK8s) TryUpdatePodCacheAnnotation ¶
TryUpdatePodCacheAnnotation is to try updating pod annotation in both api server and cache
func (*ClientK8s) UpdateConfigMap ¶
UpdateConfigMap update device info, which is cm
func (*ClientK8s) WriteDeviceInfoDataIntoCM ¶
func (ki *ClientK8s) WriteDeviceInfoDataIntoCM(deviceInfo map[string]string, manuallySeparateNPU string, switchInfo common.SwitchFaultInfo, superPodID, serverIndex int32) (*common.NodeDeviceInfoCache, error)
WriteDeviceInfoDataIntoCM write deviceinfo into config map
func (*ClientK8s) WriteDeviceInfoDataIntoCMCache ¶
func (ki *ClientK8s) WriteDeviceInfoDataIntoCMCache(deviceInfo map[string]string, manuallySeparateNPU string, switchInfo common.SwitchFaultInfo, superPodID, serverIndex int32) error
WriteDeviceInfoDataIntoCMCache write deviceinfo into config map with cache
func (*ClientK8s) WriteFaultInfoDataIntoCM ¶
func (ki *ClientK8s) WriteFaultInfoDataIntoCM(taskName string, namespace string, faultInfo *common.TaskFaultInfo) (*v1.ConfigMap, error)
WriteFaultInfoDataIntoCM write fault info into config map
type Event ¶
type Event struct { // ResourceType is the type of the resource that is being watched Resource ResourceType // Key is namespace/name Key string // Type is the type of the event Type EventType }
Event is the event that will be sent to the watcher
type ResourceType ¶
type ResourceType string
ResourceType string type of resource
const ( // PodResource is used when the event is related to a pod PodResource ResourceType = "pod" // CMResource is used when the event is related to a configmap CMResource ResourceType = "configmap" )